summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-10 00:09:20 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-10 00:09:20 +0000
commit08e0bc16b3312c27e87d33be7dcf3d4fe5bdd2e2 (patch)
tree062040f563583f0cc41fe81fc95b3c3c6d643207
parenta1364be341550d71dff27dd8de0c6872ba6c707e (diff)
Kill of the Decl::PCHLevel field entirely. We now only need to know
whether a Decl was deserialized from an AST file (any AST file). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139438 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclBase.h31
-rw-r--r--include/clang/Frontend/ASTUnit.h4
-rw-r--r--lib/Frontend/ASTUnit.cpp7
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp2
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp15
-rw-r--r--test/Index/c-index-pch.c5
-rw-r--r--tools/libclang/CIndex.cpp20
7 files changed, 12 insertions, 72 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 4cfe32c448..306a4031d5 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -250,9 +250,9 @@ protected:
unsigned Access : 2;
friend class CXXClassMemberWrapper;
- /// PCHLevel - the "level" of AST file from which this declaration was built.
- unsigned PCHLevel : 2;
-
+ /// \brief Whether this declaration was loaded from an AST file.
+ unsigned FromASTFile : 1;
+
/// ChangedAfterLoad - if this declaration has changed since being loaded
unsigned ChangedAfterLoad : 1;
@@ -285,7 +285,7 @@ protected:
: NextDeclInContext(0), DeclCtx(DC),
Loc(L), DeclKind(DK), InvalidDecl(0),
HasAttrs(false), Implicit(false), Used(false), Referenced(false),
- Access(AS_none), PCHLevel(0), ChangedAfterLoad(false),
+ Access(AS_none), FromASTFile(0), ChangedAfterLoad(false),
ModulePrivate(0),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -296,7 +296,7 @@ protected:
Decl(Kind DK, EmptyShell Empty)
: NextDeclInContext(0), DeclKind(DK), InvalidDecl(0),
HasAttrs(false), Implicit(false), Used(false), Referenced(false),
- Access(AS_none), PCHLevel(0), ChangedAfterLoad(false),
+ Access(AS_none), FromASTFile(0), ChangedAfterLoad(false),
ModulePrivate(0),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -501,29 +501,10 @@ public:
/// declaration cannot be weak-imported because it has a definition.
bool canBeWeakImported(bool &IsDefinition) const;
- /// \brief Retrieve the level of precompiled header from which this
- /// declaration was generated.
- ///
- /// The PCH level of a declaration describes where the declaration originated
- /// from. A PCH level of 0 indicates that the declaration was parsed from
- /// source. A PCH level of 1 indicates that the declaration was loaded from
- /// a top-level AST file. A PCH level 2 indicates that the declaration was
- /// loaded from a PCH file the AST file depends on, and so on.
- unsigned getPCHLevel() const { return PCHLevel; }
-
/// \brief Determine whether this declaration came from an AST file (such as
/// a precompiled header or module) rather than having been parsed.
- bool isFromASTFile() const { return PCHLevel > 0; }
+ bool isFromASTFile() const { return FromASTFile; }
- /// \brief The maximum PCH level that any declaration may have.
- static const unsigned MaxPCHLevel = 3;
-
- /// \brief Set the PCH level of this declaration.
- void setPCHLevel(unsigned Level) {
- assert(Level <= MaxPCHLevel && "PCH level exceeds the maximum");
- PCHLevel = Level;
- }
-
/// \brief Query whether this declaration was changed in a significant way
/// since being loaded from an AST file.
///
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 2fc1491c1a..e2fa5574fe 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -451,10 +451,6 @@ public:
bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }
void setOwnsRemappedFileBuffers(bool val) { OwnsRemappedFileBuffers = val; }
- /// \brief Retrieve the maximum PCH level of declarations that a
- /// traversal of the translation unit should consider.
- unsigned getMaxPCHLevel() const;
-
void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; }
ASTLocation getLastASTLocation() const { return LastLoc; }
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 190bc49a85..a680d9254b 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -1563,13 +1563,6 @@ ASTUnit::pp_entity_iterator ASTUnit::pp_entity_end() {
return PreprocessedEntities.end();
}
-unsigned ASTUnit::getMaxPCHLevel() const {
- if (!getOnlyLocalDecls())
- return Decl::MaxPCHLevel;
-
- return 0;
-}
-
StringRef ASTUnit::getMainFileName() const {
return Invocation->getFrontendOpts().Inputs[0].second;
}
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index c584181a4c..594dc93325 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -247,7 +247,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
D->setUsed(Record[Idx++]);
D->setReferenced(Record[Idx++]);
D->setAccess((AccessSpecifier)Record[Idx++]);
- D->setPCHLevel(Record[Idx++] + (F.Kind <= MK_PCH));
+ D->FromASTFile = true;
D->ModulePrivate = Record[Idx++];
}
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp
index 381cd126b7..112ccb1d4b 100644
--- a/lib/Serialization/ASTWriterDecl.cpp
+++ b/lib/Serialization/ASTWriterDecl.cpp
@@ -155,7 +155,6 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
Record.push_back(D->isUsed(false));
Record.push_back(D->isReferenced());
Record.push_back(D->getAccess());
- Record.push_back(D->PCHLevel);
Record.push_back(D->ModulePrivate);
}
@@ -181,7 +180,6 @@ void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
@@ -230,7 +228,6 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
@@ -254,7 +251,6 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
@@ -476,7 +472,6 @@ void ASTDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) {
!D->isUsed(false) &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
- !D->isFromASTFile() &&
!D->isModulePrivate() &&
!D->getBitWidth() &&
!D->hasExtInfo() &&
@@ -615,7 +610,6 @@ void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
!D->isUsed(false) &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
- !D->isFromASTFile() &&
!D->isModulePrivate() &&
!D->getBitWidth() &&
!D->hasInClassInitializer() &&
@@ -670,7 +664,6 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
!D->isReferenced() &&
D->getAccess() == AS_none &&
!D->isModulePrivate() &&
- !D->isFromASTFile() &&
D->getDeclName().getNameKind() == DeclarationName::Identifier &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == D &&
@@ -712,7 +705,6 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
!D->isUsed(false) &&
D->getAccess() == AS_none &&
!D->isModulePrivate() &&
- !D->isFromASTFile() &&
D->getStorageClass() == 0 &&
!D->hasCXXDirectInitializer() && // Can params have this ever?
D->getFunctionScopeDepth() == 0 &&
@@ -1272,7 +1264,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1304,7 +1295,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1339,7 +1329,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1385,7 +1374,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1425,7 +1413,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1474,7 +1461,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
@@ -1500,7 +1486,6 @@ void ASTWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
- Abv->Add(BitCodeAbbrevOp(0)); // PCH level
Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
diff --git a/test/Index/c-index-pch.c b/test/Index/c-index-pch.c
index 2037fc5880..313fae88f4 100644
--- a/test/Index/c-index-pch.c
+++ b/test/Index/c-index-pch.c
@@ -1,14 +1,9 @@
// RUN: %clang_cc1 -emit-pch -x c -o %t.pch %S/Inputs/c-index-pch.h
// RUN: %clang_cc1 -include-pch %t.pch -x c -emit-pch -o %t.ast %s
// RUN: c-index-test -test-load-tu %t.ast all | FileCheck -check-prefix=ALL %s
-// RUN: c-index-test -test-load-tu %t.ast local | FileCheck -check-prefix=LOCAL %s
// ALL: FunctionDecl=foo
// ALL: VarDecl=bar
// ALL: FunctionDecl=wibble
// ALL: FunctionDecl=wonka
-// LOCAL-NOT: FunctionDecl=foo
-// LOCAL-NOT: VarDecl=bar
-// LOCAL: FunctionDecl=wibble
-// LOCAL: FunctionDecl=wonka
void wibble(int i);
void wonka(float);
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index fcd6459d4f..e6e1b90534 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -183,11 +183,6 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
/// \brief The opaque client data, to be passed along to the visitor.
CXClientData ClientData;
- // MaxPCHLevel - the maximum PCH level of declarations that we will pass on
- // to the visitor. Declarations with a PCH level greater than this value will
- // be suppressed.
- unsigned MaxPCHLevel;
-
/// \brief Whether we should visit the preprocessing record entries last,
/// after visiting other declarations.
bool VisitPreprocessorLast;
@@ -238,12 +233,11 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
public:
CursorVisitor(CXTranslationUnit TU, CXCursorVisitor Visitor,
CXClientData ClientData,
- unsigned MaxPCHLevel,
bool VisitPreprocessorLast,
SourceRange RegionOfInterest = SourceRange())
: TU(TU), AU(static_cast<ASTUnit*>(TU->TUData)),
Visitor(Visitor), ClientData(ClientData),
- MaxPCHLevel(MaxPCHLevel), VisitPreprocessorLast(VisitPreprocessorLast),
+ VisitPreprocessorLast(VisitPreprocessorLast),
RegionOfInterest(RegionOfInterest), DI_current(0)
{
Parent.kind = CXCursor_NoDeclFound;
@@ -375,9 +369,6 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
if (clang_isDeclaration(Cursor.kind)) {
Decl *D = getCursorDecl(Cursor);
assert(D && "Invalid declaration cursor");
- if (D->getPCHLevel() > MaxPCHLevel)
- return false;
-
if (D->isImplicit())
return false;
}
@@ -3030,7 +3021,6 @@ unsigned clang_visitChildren(CXCursor parent,
CXCursorVisitor visitor,
CXClientData client_data) {
CursorVisitor CursorVis(getCursorTU(parent), visitor, client_data,
- getCursorASTUnit(parent)->getMaxPCHLevel(),
false);
return CursorVis.VisitChildren(parent);
}
@@ -3527,7 +3517,8 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
GetCursorData ResultData(CXXUnit->getSourceManager(), SLoc, Result);
CXCursor Parent = clang_getTranslationUnitCursor(TU);
CursorVisitor CursorVis(TU, GetCursorVisitor, &ResultData,
- Decl::MaxPCHLevel, true, SourceLocation(SLoc));
+ /*VisitPreprocessorLast=*/true,
+ SourceLocation(SLoc));
CursorVis.VisitChildren(Parent);
}
@@ -4564,8 +4555,7 @@ public:
: Annotated(annotated), Tokens(tokens), Cursors(cursors),
NumTokens(numTokens), TokIdx(0), PreprocessingTokIdx(0),
AnnotateVis(tu,
- AnnotateTokensVisitor, this,
- Decl::MaxPCHLevel, true, RegionOfInterest),
+ AnnotateTokensVisitor, this, true, RegionOfInterest),
SrcMgr(static_cast<ASTUnit*>(tu->TUData)->getSourceManager()),
HasContextSensitiveKeywords(false) { }
@@ -5029,7 +5019,7 @@ static void clang_annotateTokensImpl(void *UserData) {
Tokens, NumTokens);
CursorVisitor MacroArgMarker(TU,
MarkMacroArgTokensVisitorDelegate, &Visitor,
- Decl::MaxPCHLevel, true, RegionOfInterest);
+ true, RegionOfInterest);
MacroArgMarker.visitPreprocessedEntitiesInRegion();
}