When indexing a module file, for the ppIncludedFile callback give
an invalid location if the location points to the synthetic buffer
for the module input.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165592 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 136e72a..6a4f0eb 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -512,8 +512,9 @@
Predefines(Predefines), Counter(Counter), NumHeaderInfos(0),
InitializedLanguage(false) {}
- virtual bool ReadLanguageOptions(const LangOptions &LangOpts) {
- if (InitializedLanguage)
+ virtual bool ReadLanguageOptions(const serialization::ModuleFile &M,
+ const LangOptions &LangOpts) {
+ if (InitializedLanguage || M.Kind != serialization::MK_MainFile)
return false;
LangOpt = LangOpts;
@@ -530,9 +531,10 @@
return false;
}
- virtual bool ReadTargetTriple(StringRef Triple) {
+ virtual bool ReadTargetTriple(const serialization::ModuleFile &M,
+ StringRef Triple) {
// If we've already initialized the target, don't do it again.
- if (Target)
+ if (Target || M.Kind != serialization::MK_MainFile)
return false;
// FIXME: This is broken, we should store the TargetOptions in the AST file.
@@ -563,7 +565,7 @@
HSI.setHeaderFileInfoForUID(HFI, NumHeaderInfos++);
}
- virtual void ReadCounter(unsigned Value) {
+ virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value) {
Counter = Value;
}
@@ -2852,6 +2854,10 @@
return 0;
}
+bool ASTUnit::isModuleFile() {
+ return isMainFileAST() && !ASTFileLangOpts.CurrentModule.empty();
+}
+
void ASTUnit::PreambleData::countLines() const {
NumLines = 0;
if (empty())