forked from OSchip/llvm-project
Mark a TagDecl when it is free standing (e.g. "struct foo;")
llvm-svn: 140894
This commit is contained in:
parent
6535dae3b7
commit
201d377109
|
@ -2352,6 +2352,9 @@ private:
|
|||
/// in the syntax of a declarator.
|
||||
bool IsEmbeddedInDeclarator : 1;
|
||||
|
||||
/// /brief True if this tag is free standing, e.g. "struct foo;".
|
||||
bool IsFreeStanding : 1;
|
||||
|
||||
protected:
|
||||
// These are used by (and only defined for) EnumDecl.
|
||||
unsigned NumPositiveBits : 8;
|
||||
|
@ -2402,6 +2405,7 @@ protected:
|
|||
IsDefinition = false;
|
||||
IsBeingDefined = false;
|
||||
IsEmbeddedInDeclarator = false;
|
||||
IsFreeStanding = false;
|
||||
setPreviousDeclaration(PrevDecl);
|
||||
}
|
||||
|
||||
|
@ -2462,6 +2466,11 @@ public:
|
|||
IsEmbeddedInDeclarator = isInDeclarator;
|
||||
}
|
||||
|
||||
bool isFreeStanding() const { return IsFreeStanding; }
|
||||
void setFreeStanding(bool isFreeStanding = true) {
|
||||
IsFreeStanding = isFreeStanding;
|
||||
}
|
||||
|
||||
/// \brief Whether this declaration declares a type that is
|
||||
/// dependent, i.e., a type that somehow depends on template
|
||||
/// parameters.
|
||||
|
|
|
@ -2249,6 +2249,9 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
|
|||
Tag = dyn_cast<TagDecl>(TagD);
|
||||
}
|
||||
|
||||
if (Tag)
|
||||
Tag->setFreeStanding();
|
||||
|
||||
if (unsigned TypeQuals = DS.getTypeQualifiers()) {
|
||||
// Enforce C99 6.7.3p2: "Types other than pointer types derived from object
|
||||
// or incomplete types shall not be restrict-qualified."
|
||||
|
|
|
@ -284,6 +284,7 @@ void ASTDeclReader::VisitTagDecl(TagDecl *TD) {
|
|||
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
|
||||
TD->setDefinition(Record[Idx++]);
|
||||
TD->setEmbeddedInDeclarator(Record[Idx++]);
|
||||
TD->setFreeStanding(Record[Idx++]);
|
||||
TD->setRBraceLoc(ReadSourceLocation(Record, Idx));
|
||||
if (Record[Idx++]) { // hasExtInfo
|
||||
TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo();
|
||||
|
|
|
@ -204,6 +204,7 @@ void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
|
|||
Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
|
||||
Record.push_back(D->isDefinition());
|
||||
Record.push_back(D->isEmbeddedInDeclarator());
|
||||
Record.push_back(D->isFreeStanding());
|
||||
Writer.AddSourceLocation(D->getRBraceLoc(), Record);
|
||||
Record.push_back(D->hasExtInfo());
|
||||
if (D->hasExtInfo())
|
||||
|
@ -1343,6 +1344,7 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
|
|||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isDefinition
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
|
||||
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypedefNameAnonDecl
|
||||
|
@ -1388,6 +1390,7 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
|
|||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isDefinition
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
|
||||
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
|
||||
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypedefNameAnonDecl
|
||||
|
|
Loading…
Reference in New Issue