Improve representation of tag declarations first declared or defined
within the declarator of another declaration, from Enea Zaffanella! llvm-svn: 95991
This commit is contained in:
parent
5272c2574a
commit
5089c769bb
|
|
@ -1511,9 +1511,10 @@ private:
|
||||||
/// it is a declaration ("struct foo;").
|
/// it is a declaration ("struct foo;").
|
||||||
bool IsDefinition : 1;
|
bool IsDefinition : 1;
|
||||||
|
|
||||||
/// IsDefinedInDeclarator - True if this tag declaration is
|
/// IsEmbeddedInDeclarator - True if this tag declaration is
|
||||||
/// syntactically defined in a declarator.
|
/// "embedded" (i.e., defined or declared for the very first time)
|
||||||
bool IsDefinedInDeclarator : 1;
|
/// in the syntax of a declarator,
|
||||||
|
bool IsEmbeddedInDeclarator : 1;
|
||||||
|
|
||||||
/// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef,
|
/// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef,
|
||||||
/// this points to the TypedefDecl. Used for mangling.
|
/// this points to the TypedefDecl. Used for mangling.
|
||||||
|
|
@ -1531,7 +1532,7 @@ protected:
|
||||||
assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
|
assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
|
||||||
TagDeclKind = TK;
|
TagDeclKind = TK;
|
||||||
IsDefinition = false;
|
IsDefinition = false;
|
||||||
IsDefinedInDeclarator = false;
|
IsEmbeddedInDeclarator = false;
|
||||||
setPreviousDeclaration(PrevDecl);
|
setPreviousDeclaration(PrevDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1565,11 +1566,11 @@ public:
|
||||||
return IsDefinition;
|
return IsDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDefinedInDeclarator() const {
|
bool isEmbeddedInDeclarator() const {
|
||||||
return IsDefinedInDeclarator;
|
return IsEmbeddedInDeclarator;
|
||||||
}
|
}
|
||||||
void setDefinedInDeclarator(bool isInDeclarator) {
|
void setEmbeddedInDeclarator(bool isInDeclarator) {
|
||||||
IsDefinedInDeclarator = isInDeclarator;
|
IsEmbeddedInDeclarator = isInDeclarator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Whether this declaration declares a type that is
|
/// \brief Whether this declaration declares a type that is
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ void PCHDeclReader::VisitTagDecl(TagDecl *TD) {
|
||||||
cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++])));
|
cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
|
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
|
||||||
TD->setDefinition(Record[Idx++]);
|
TD->setDefinition(Record[Idx++]);
|
||||||
TD->setDefinedInDeclarator(Record[Idx++]);
|
TD->setEmbeddedInDeclarator(Record[Idx++]);
|
||||||
TD->setTypedefForAnonDecl(
|
TD->setTypedefForAnonDecl(
|
||||||
cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
|
cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ void PCHDeclWriter::VisitTagDecl(TagDecl *D) {
|
||||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||||
Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
|
Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
|
||||||
Record.push_back(D->isDefinition());
|
Record.push_back(D->isDefinition());
|
||||||
Record.push_back(D->isDefinedInDeclarator());
|
Record.push_back(D->isEmbeddedInDeclarator());
|
||||||
Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record);
|
Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record);
|
||||||
Writer.AddSourceLocation(D->getRBraceLoc(), Record);
|
Writer.AddSourceLocation(D->getRBraceLoc(), Record);
|
||||||
Writer.AddSourceLocation(D->getTagKeywordLoc(), Record);
|
Writer.AddSourceLocation(D->getTagKeywordLoc(), Record);
|
||||||
|
|
|
||||||
|
|
@ -930,7 +930,10 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
|
||||||
|
|
||||||
if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) {
|
if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) {
|
||||||
TagDecl* Owned = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep());
|
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;
|
if (OwnedDecl) *OwnedDecl = Owned;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue