Add a "TypeSpecStartLoc" to FieldDecl. Patch contributed by Enea Zaffanella.
Note: One day, it might be useful to consider adding this info to DeclGroup (as the comments in FunctionDecl/VarDecl suggest). For now, I think this works fine. I considered moving this to ValueDecl (a common ancestor of FunctionDecl/VarDecl/FieldDecl), however this would add overhead to EnumConstantDecl (which would burn memory and isn't necessary).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75635 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index e11729b..5fbf2d7 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -333,6 +333,7 @@
void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) {
VisitValueDecl(FD);
FD->setMutable(Record[Idx++]);
+ FD->setTypeSpecStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
if (Record[Idx++])
FD->setBitWidth(Reader.ReadDeclExpr());
}
@@ -667,7 +668,7 @@
break;
case pch::DECL_FIELD:
D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
- false);
+ false, SourceLocation());
break;
case pch::DECL_VAR:
D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(),
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index 6aed0e9..ff5c576 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -325,6 +325,7 @@
void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) {
VisitValueDecl(D);
Record.push_back(D->isMutable());
+ Writer.AddSourceLocation(D->getTypeSpecStartLoc(), Record);
Record.push_back(D->getBitWidth()? 1 : 0);
if (D->getBitWidth())
Writer.AddStmt(D->getBitWidth());