[cfe-commits] r95991 - in /cfe/trunk: include/clang/AST/Decl.h lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp lib/Sema/SemaType.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 12 09:40:35 PST 2010
Author: dgregor
Date: Fri Feb 12 11:40:34 2010
New Revision: 95991
URL: http://llvm.org/viewvc/llvm-project?rev=95991&view=rev
Log:
Improve representation of tag declarations first declared or defined
within the declarator of another declaration, from Enea Zaffanella!
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=95991&r1=95990&r2=95991&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Feb 12 11:40:34 2010
@@ -1511,9 +1511,10 @@
/// it is a declaration ("struct foo;").
bool IsDefinition : 1;
- /// IsDefinedInDeclarator - True if this tag declaration is
- /// syntactically defined in a declarator.
- bool IsDefinedInDeclarator : 1;
+ /// IsEmbeddedInDeclarator - True if this tag declaration is
+ /// "embedded" (i.e., defined or declared for the very first time)
+ /// in the syntax of a declarator,
+ bool IsEmbeddedInDeclarator : 1;
/// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef,
/// this points to the TypedefDecl. Used for mangling.
@@ -1531,7 +1532,7 @@
assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
TagDeclKind = TK;
IsDefinition = false;
- IsDefinedInDeclarator = false;
+ IsEmbeddedInDeclarator = false;
setPreviousDeclaration(PrevDecl);
}
@@ -1565,11 +1566,11 @@
return IsDefinition;
}
- bool isDefinedInDeclarator() const {
- return IsDefinedInDeclarator;
+ bool isEmbeddedInDeclarator() const {
+ return IsEmbeddedInDeclarator;
}
- void setDefinedInDeclarator(bool isInDeclarator) {
- IsDefinedInDeclarator = isInDeclarator;
+ void setEmbeddedInDeclarator(bool isInDeclarator) {
+ IsEmbeddedInDeclarator = isInDeclarator;
}
/// \brief Whether this declaration declares a type that is
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=95991&r1=95990&r2=95991&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Fri Feb 12 11:40:34 2010
@@ -117,7 +117,7 @@
cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++])));
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
TD->setDefinition(Record[Idx++]);
- TD->setDefinedInDeclarator(Record[Idx++]);
+ TD->setEmbeddedInDeclarator(Record[Idx++]);
TD->setTypedefForAnonDecl(
cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=95991&r1=95990&r2=95991&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Fri Feb 12 11:40:34 2010
@@ -115,7 +115,7 @@
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
Record.push_back(D->isDefinition());
- Record.push_back(D->isDefinedInDeclarator());
+ Record.push_back(D->isEmbeddedInDeclarator());
Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record);
Writer.AddSourceLocation(D->getRBraceLoc(), Record);
Writer.AddSourceLocation(D->getTagKeywordLoc(), Record);
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=95991&r1=95990&r2=95991&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Feb 12 11:40:34 2010
@@ -930,7 +930,10 @@
if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) {
TagDecl* Owned = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep());
- Owned->setDefinedInDeclarator(Owned->isDefinition());
+ // Owned is embedded if it was defined here, or if it is the
+ // very first (i.e., canonical) declaration of this tag type.
+ Owned->setEmbeddedInDeclarator(Owned->isDefinition() ||
+ Owned->isCanonicalDecl());
if (OwnedDecl) *OwnedDecl = Owned;
}
break;
More information about the cfe-commits
mailing list