Introduce a new predicate Decl::isFromASTFile() to determine whether a
declaration was deserialized from an AST file. Use this instead of
Decl::getPCHLevel() wherever possible. This is a simple step toward
killing off Decl::getPCHLevel().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139427 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 14d811f..4cfe32c 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -511,6 +511,10 @@
/// 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; }
+
/// \brief The maximum PCH level that any declaration may have.
static const unsigned MaxPCHLevel = 3;
diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h
index 1fa9066..ce762b8 100644
--- a/include/clang/Sema/Lookup.h
+++ b/include/clang/Sema/Lookup.h
@@ -274,7 +274,7 @@
// So long as this declaration is not module-private or was parsed as
// part of this translation unit (i.e., in the module), we're allowed to
// find it.
- if (!D->isModulePrivate() || D->getPCHLevel() == 0)
+ if (!D->isModulePrivate() || !D->isFromASTFile())
return true;
// FIXME: We should be allowed to refer to a module-private name from