diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-08 22:07:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-08 22:07:33 +0000 |
commit | 591bd3cb605f1f0229b4b1d8a4b8183377064ec5 (patch) | |
tree | 06177704cc8d79e6a9e506c996e0c7f1f890e678 | |
parent | 88786862424cb2d478516d911709dc19c962af9c (diff) |
Keep track of whether a tag was defined in a declarator vs. being
defined by itself, from Enea Zaffanella!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95586 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Decl.h | 12 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/PCHWriterDecl.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 7 |
4 files changed, 19 insertions, 2 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 8166316fcc..58fb01d4fc 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1512,6 +1512,10 @@ private: /// it is a declaration ("struct foo;"). bool IsDefinition : 1; + /// IsDefinedInDeclarator - True if this tag declaration is + /// syntactically defined in a declarator. + bool IsDefinedInDeclarator : 1; + /// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef, /// this points to the TypedefDecl. Used for mangling. TypedefDecl *TypedefForAnonDecl; @@ -1528,6 +1532,7 @@ protected: assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum"); TagDeclKind = TK; IsDefinition = false; + IsDefinedInDeclarator = false; setPreviousDeclaration(PrevDecl); } @@ -1561,6 +1566,13 @@ public: return IsDefinition; } + bool isDefinedInDeclarator() const { + return IsDefinedInDeclarator; + } + void setDefinedInDeclarator(bool isInDeclarator) { + IsDefinedInDeclarator = isInDeclarator; + } + /// \brief Whether this declaration declares a type that is /// dependent, i.e., a type that somehow depends on template /// parameters. diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 4dc1318a3e..56cdfc6192 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -117,6 +117,7 @@ void PCHDeclReader::VisitTagDecl(TagDecl *TD) { cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++]))); TD->setTagKind((TagDecl::TagKind)Record[Idx++]); TD->setDefinition(Record[Idx++]); + TD->setDefinedInDeclarator(Record[Idx++]); TD->setTypedefForAnonDecl( cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 020f69b3e6..1901b2fad6 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -115,6 +115,7 @@ void PCHDeclWriter::VisitTagDecl(TagDecl *D) { Writer.AddDeclRef(D->getPreviousDeclaration(), Record); Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding Record.push_back(D->isDefinition()); + Record.push_back(D->isDefinedInDeclarator()); Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record); Writer.AddSourceLocation(D->getRBraceLoc(), Record); Writer.AddSourceLocation(D->getTagKeywordLoc(), Record); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 3ef13a2aba..ceec5f226f 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -928,8 +928,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, case UnqualifiedId::IK_TemplateId: T = ConvertDeclSpecToType(*this, D, FnAttrsFromDeclSpec); - if (!D.isInvalidType() && OwnedDecl && D.getDeclSpec().isTypeSpecOwned()) - *OwnedDecl = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep()); + if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) { + TagDecl* Owned = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep()); + Owned->setDefinedInDeclarator(Owned->isDefinition()); + if (OwnedDecl) *OwnedDecl = Owned; + } break; case UnqualifiedId::IK_ConstructorName: |