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;
: 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)
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)
/// 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.
///
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; }
return PreprocessedEntities.end();
}
-unsigned ASTUnit::getMaxPCHLevel() const {
- if (!getOnlyLocalDecls())
- return Decl::MaxPCHLevel;
-
- return 0;
-}
-
StringRef ASTUnit::getMainFileName() const {
return Invocation->getFrontendOpts().Inputs[0].second;
}
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++];
}
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);
}
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
if (!D->hasAttrs() &&
!D->isImplicit() &&
!D->isUsed(false) &&
- !D->isFromASTFile() &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == D &&
!D->isInvalidDecl() &&
!D->isUsed(false) &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
- !D->isFromASTFile() &&
!D->isModulePrivate() &&
!D->getBitWidth() &&
!D->hasExtInfo() &&
!D->isUsed(false) &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
- !D->isFromASTFile() &&
!D->isModulePrivate() &&
!D->getBitWidth() &&
!D->hasInClassInitializer() &&
!D->isReferenced() &&
D->getAccess() == AS_none &&
!D->isModulePrivate() &&
- !D->isFromASTFile() &&
D->getDeclName().getNameKind() == DeclarationName::Identifier &&
!D->hasExtInfo() &&
D->RedeclLink.getNext() == 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 &&
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
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
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
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
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
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
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
// 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);
/// \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;
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;
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;
}
CXCursorVisitor visitor,
CXClientData client_data) {
CursorVisitor CursorVis(getCursorTU(parent), visitor, client_data,
- getCursorASTUnit(parent)->getMaxPCHLevel(),
false);
return CursorVis.VisitChildren(parent);
}
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);
}
: 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) { }
Tokens, NumTokens);
CursorVisitor MacroArgMarker(TU,
MarkMacroArgTokensVisitorDelegate, &Visitor,
- Decl::MaxPCHLevel, true, RegionOfInterest);
+ true, RegionOfInterest);
MacroArgMarker.visitPreprocessedEntitiesInRegion();
}