diff options
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 572d76f..4d0d422 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -38,7 +38,7 @@ void Attr::Destroy(ASTContext &C) { } /// \brief Return the TypeLoc wrapper for the type source info. -TypeLoc DeclaratorInfo::getTypeLoc() const { +TypeLoc TypeSourceInfo::getTypeLoc() const { return TypeLoc(Ty, (void*)(this + 1)); } @@ -86,17 +86,17 @@ const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) { ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - QualType T, DeclaratorInfo *DInfo, + QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg) { - return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, DInfo, S, DefArg); + return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, TInfo, S, DefArg); } SourceRange ParmVarDecl::getDefaultArgRange() const { if (const Expr *E = getInit()) return E->getSourceRange(); - if (const Expr *E = getUninstantiatedDefaultArg()) - return E->getSourceRange(); + if (hasUninstantiatedDefaultArg()) + return getUninstantiatedDefaultArg()->getSourceRange(); return SourceRange(); } @@ -136,11 +136,11 @@ bool VarDecl::isExternC() const { FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, - DeclaratorInfo *DInfo, + TypeSourceInfo *TInfo, StorageClass S, bool isInline, bool hasWrittenPrototype) { FunctionDecl *New - = new (C) FunctionDecl(Function, DC, L, N, T, DInfo, S, isInline); + = new (C) FunctionDecl(Function, DC, L, N, T, TInfo, S, isInline); New->HasWrittenPrototype = hasWrittenPrototype; return New; } @@ -151,8 +151,8 @@ BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, - DeclaratorInfo *DInfo, Expr *BW, bool Mutable) { - return new (C) FieldDecl(Decl::Field, DC, L, Id, T, DInfo, BW, Mutable); + TypeSourceInfo *TInfo, Expr *BW, bool Mutable) { + return new (C) FieldDecl(Decl::Field, DC, L, Id, T, TInfo, BW, Mutable); } bool FieldDecl::isAnonymousStructOrUnion() const { @@ -179,8 +179,8 @@ void EnumConstantDecl::Destroy(ASTContext& C) { TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - DeclaratorInfo *DInfo) { - return new (C) TypedefDecl(DC, L, Id, DInfo); + TypeSourceInfo *TInfo) { + return new (C) TypedefDecl(DC, L, Id, TInfo); } EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -195,9 +195,12 @@ void EnumDecl::Destroy(ASTContext& C) { Decl::Destroy(C); } -void EnumDecl::completeDefinition(ASTContext &C, QualType NewType) { +void EnumDecl::completeDefinition(ASTContext &C, + QualType NewType, + QualType NewPromotionType) { assert(!isDefinition() && "Cannot redefine enums!"); IntegerType = NewType; + PromotionType = NewPromotionType; TagDecl::completeDefinition(); } @@ -535,9 +538,9 @@ SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const { //===----------------------------------------------------------------------===// VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, + IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S) { - return new (C) VarDecl(Var, DC, L, Id, T, DInfo, S); + return new (C) VarDecl(Var, DC, L, Id, T, TInfo, S); } void VarDecl::Destroy(ASTContext& C) { @@ -838,8 +841,20 @@ unsigned FunctionDecl::getMinRequiredArguments() const { } bool FunctionDecl::isInlined() const { - if (isInlineSpecified() || (isa<CXXMethodDecl>(this) && !isOutOfLine())) + // FIXME: This is not enough. Consider: + // + // inline void f(); + // void f() { } + // + // f is inlined, but does not have inline specified. + // To fix this we should add an 'inline' flag to FunctionDecl. + if (isInlineSpecified()) return true; + + if (isa<CXXMethodDecl>(this)) { + if (!isOutOfLine() || getCanonicalDecl()->isInlineSpecified()) + return true; + } switch (getTemplateSpecializationKind()) { case TSK_Undeclared: @@ -1199,7 +1214,7 @@ TagDecl* TagDecl::getDefinition(ASTContext& C) const { TagDecl::TagKind TagDecl::getTagKindForTypeSpec(unsigned TypeSpec) { switch (TypeSpec) { - default: llvm::llvm_unreachable("unexpected type specifier"); + default: llvm_unreachable("unexpected type specifier"); case DeclSpec::TST_struct: return TK_struct; case DeclSpec::TST_class: return TK_class; case DeclSpec::TST_union: return TK_union; |