forked from OSchip/llvm-project
Make parse-ast-print print the storage class and inline
specifier of functions. llvm-svn: 41416
This commit is contained in:
parent
1c72d77d01
commit
b677a9398a
|
@ -47,6 +47,18 @@ void clang::BuildASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) {
|
||||||
static void PrintFunctionDeclStart(FunctionDecl *FD) {
|
static void PrintFunctionDeclStart(FunctionDecl *FD) {
|
||||||
bool HasBody = FD->getBody();
|
bool HasBody = FD->getBody();
|
||||||
|
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
switch (FD->getStorageClass()) {
|
||||||
|
default: assert(0 && "Unknown storage class");
|
||||||
|
case FunctionDecl::None: break;
|
||||||
|
case FunctionDecl::Extern: fprintf(stderr, "extern "); break;
|
||||||
|
case FunctionDecl::Static: fprintf(stderr, "static "); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FD->isInline())
|
||||||
|
fprintf(stderr, "inline ");
|
||||||
|
|
||||||
std::string Proto = FD->getName();
|
std::string Proto = FD->getName();
|
||||||
FunctionType *AFT = cast<FunctionType>(FD->getType());
|
FunctionType *AFT = cast<FunctionType>(FD->getType());
|
||||||
|
|
||||||
|
@ -72,7 +84,7 @@ static void PrintFunctionDeclStart(FunctionDecl *FD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AFT->getResultType().getAsStringInternal(Proto);
|
AFT->getResultType().getAsStringInternal(Proto);
|
||||||
fprintf(stderr, "\n%s", Proto.c_str());
|
fprintf(stderr, "%s", Proto.c_str());
|
||||||
|
|
||||||
if (!FD->getBody())
|
if (!FD->getBody())
|
||||||
fprintf(stderr, ";\n");
|
fprintf(stderr, ";\n");
|
||||||
|
|
|
@ -156,7 +156,7 @@ Decl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, Scope *S) {
|
||||||
|
|
||||||
QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);
|
QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);
|
||||||
FunctionDecl *New = new FunctionDecl(SourceLocation(), II, R,
|
FunctionDecl *New = new FunctionDecl(SourceLocation(), II, R,
|
||||||
FunctionDecl::Extern, 0);
|
FunctionDecl::Extern, false, 0);
|
||||||
|
|
||||||
// Find translation-unit scope to insert this function into.
|
// Find translation-unit scope to insert this function into.
|
||||||
while (S->getParent())
|
while (S->getParent())
|
||||||
|
@ -334,6 +334,7 @@ Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *init,
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
|
FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
|
||||||
|
D.getDeclSpec().isInlineSpecified(),
|
||||||
LastDeclarator);
|
LastDeclarator);
|
||||||
|
|
||||||
// Merge the decl with the existing one if appropriate.
|
// Merge the decl with the existing one if appropriate.
|
||||||
|
|
|
@ -239,9 +239,9 @@ public:
|
||||||
None, Extern, Static
|
None, Extern, Static
|
||||||
};
|
};
|
||||||
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||||
StorageClass S = None, Decl *PrevDecl = 0)
|
StorageClass S = None, bool isInline, Decl *PrevDecl = 0)
|
||||||
: ValueDecl(Function, L, Id, T, PrevDecl),
|
: ValueDecl(Function, L, Id, T, PrevDecl),
|
||||||
ParamInfo(0), Body(0), DeclChain(0), SClass(S) {}
|
ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
|
||||||
virtual ~FunctionDecl();
|
virtual ~FunctionDecl();
|
||||||
|
|
||||||
Stmt *getBody() const { return Body; }
|
Stmt *getBody() const { return Body; }
|
||||||
|
@ -265,6 +265,7 @@ public:
|
||||||
return cast<FunctionType>(getType())->getResultType();
|
return cast<FunctionType>(getType())->getResultType();
|
||||||
}
|
}
|
||||||
StorageClass getStorageClass() const { return SClass; }
|
StorageClass getStorageClass() const { return SClass; }
|
||||||
|
bool isInline() const { return IsInline; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Decl *D) { return D->getKind() == Function; }
|
static bool classof(const Decl *D) { return D->getKind() == Function; }
|
||||||
|
@ -282,7 +283,8 @@ private:
|
||||||
/// function.
|
/// function.
|
||||||
Decl *DeclChain;
|
Decl *DeclChain;
|
||||||
|
|
||||||
StorageClass SClass;
|
StorageClass SClass : 2;
|
||||||
|
bool IsInline : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue