aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-10-05 16:15:19 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-10-05 16:15:19 +0000
commit1d9f1fe7173e3084325f43c78af812a36d8a2a7c (patch)
tree62cc4283ca4e25e7c0a3c51f88c37d4586e01ffe /lib/Frontend
parentc3632730cc83ed7b51f0ab5c38997ae5a9439b0c (diff)
Give every file that ASTReader loads a type: module, PCH, precompiled preamble or main file. Base Decls' PCHLevel on this to make it more sane.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/ASTUnit.cpp7
-rw-r--r--lib/Frontend/CompilerInstance.cpp10
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 19d1690051..7b87d3c268 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -479,7 +479,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
Reader->setListener(new ASTInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
- switch (Reader->ReadAST(Filename)) {
+ switch (Reader->ReadAST(Filename, ASTReader::MainFile)) {
case ASTReader::Success:
break;
@@ -1305,10 +1305,7 @@ unsigned ASTUnit::getMaxPCHLevel() const {
if (!getOnlyLocalDecls())
return Decl::MaxPCHLevel;
- unsigned Result = 0;
- if (isMainFileAST() || SavedMainFileBuffer)
- ++Result;
- return Result;
+ return 0;
}
ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI,
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 212a1cf9f2..e3eb859153 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -251,10 +251,12 @@ void CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path,
bool DisablePCHValidation,
void *DeserializationListener){
llvm::OwningPtr<ExternalASTSource> Source;
+ bool Preamble = getPreprocessorOpts().PrecompiledPreambleBytes.first != 0;
Source.reset(createPCHExternalASTSource(Path, getHeaderSearchOpts().Sysroot,
DisablePCHValidation,
getPreprocessor(), getASTContext(),
- DeserializationListener));
+ DeserializationListener,
+ Preamble));
getASTContext().setExternalSource(Source);
}
@@ -264,7 +266,8 @@ CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path,
bool DisablePCHValidation,
Preprocessor &PP,
ASTContext &Context,
- void *DeserializationListener) {
+ void *DeserializationListener,
+ bool Preamble) {
llvm::OwningPtr<ASTReader> Reader;
Reader.reset(new ASTReader(PP, &Context,
Sysroot.empty() ? 0 : Sysroot.c_str(),
@@ -272,7 +275,8 @@ CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path,
Reader->setDeserializationListener(
static_cast<ASTDeserializationListener *>(DeserializationListener));
- switch (Reader->ReadAST(Path)) {
+ switch (Reader->ReadAST(Path,
+ Preamble ? ASTReader::Preamble : ASTReader::PCH)) {
case ASTReader::Success:
// Set the predefines buffer as suggested by the PCH reader. Typically, the
// predefines buffer will be empty.