[clang] fdf8e3e - [Modules][Diagnostic] Mention which AST file's options differ from the current TU options. (#101413)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 07:23:51 PDT 2024
Author: Volodymyr Sapsai
Date: 2024-08-08T11:23:47-03:00
New Revision: fdf8e3e31103bc81917cdb27150877f524bb2669
URL: https://github.com/llvm/llvm-project/commit/fdf8e3e31103bc81917cdb27150877f524bb2669
DIFF: https://github.com/llvm/llvm-project/commit/fdf8e3e31103bc81917cdb27150877f524bb2669.diff
LOG: [Modules][Diagnostic] Mention which AST file's options differ from the current TU options. (#101413)
Claiming a mismatch is always in a precompiled header is wrong and
misleading as a mismatch can happen in any provided AST file. Emitting a
path for a file with a problem allows to disambiguate between multiple
input files.
Use generic term "AST file" because we don't always know a kind of the
provided file (for example, see `ASTReader::readASTFileControlBlock`).
rdar://65005546
Added:
Modified:
clang/include/clang/Basic/DiagnosticSerializationKinds.td
clang/include/clang/Serialization/ASTReader.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/check-for-sanitizer-feature.cpp
clang/test/Modules/ignored_macros.m
clang/test/Modules/load_failure.c
clang/test/Modules/merge-target-features.cpp
clang/test/Modules/mismatch-diagnostics.cpp
clang/test/Modules/module-pch-different-cache-path.c
clang/test/Modules/pr62359.cppm
clang/test/PCH/arc.m
clang/test/PCH/fuzzy-pch.c
clang/test/PCH/module-hash-difference.m
clang/test/PCH/ms-pch-macro.c
clang/test/PCH/no-validate-pch.cl
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index 51d0abbbec252a..9854972cbfe7e4 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -29,20 +29,20 @@ def note_pch_rebuild_required : Note<"please rebuild precompiled header '%0'">;
def note_module_cache_path : Note<
"after modifying system headers, please delete the module cache at '%0'">;
-def err_pch_targetopt_mismatch : Error<
- "PCH file was compiled for the %0 '%1' but the current translation "
- "unit is being compiled for target '%2'">;
-def err_pch_targetopt_feature_mismatch : Error<
- "%select{AST file was|current translation unit is}0 compiled with the target "
- "feature '%1' but the %select{current translation unit is|AST file was}0 "
+def err_ast_file_targetopt_mismatch : Error<
+ "AST file '%0' was compiled for the %1 '%2' but the current translation "
+ "unit is being compiled for target '%3'">;
+def err_ast_file_targetopt_feature_mismatch : Error<
+ "%select{AST file '%1' was|current translation unit is}0 compiled with the target "
+ "feature '%2' but the %select{current translation unit is|AST file '%1' was}0 "
"not">;
-def err_pch_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in "
- "PCH file but is currently %select{disabled|enabled}2">;
-def err_pch_langopt_value_mismatch : Error<
- "%0
diff ers in PCH file vs. current file">;
-def err_pch_diagopt_mismatch : Error<"%0 is currently enabled, but was not in "
- "the PCH file">;
-def err_pch_modulecache_mismatch : Error<"PCH was compiled with module cache "
+def err_ast_file_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in "
+ "AST file '%3' but is currently %select{disabled|enabled}2">;
+def err_ast_file_langopt_value_mismatch : Error<
+ "%0
diff ers in AST file '%1' vs. current file">;
+def err_ast_file_diagopt_mismatch : Error<"%0 is currently enabled, but was not in "
+ "the AST file '%1'">;
+def err_ast_file_modulecache_mismatch : Error<"AST file '%2' was compiled with module cache "
"path '%0', but the path is currently '%1'">;
def warn_pch_vfsoverlay_mismatch : Warning<
"PCH was compiled with
diff erent VFS overlay files than are currently in use">,
@@ -99,19 +99,19 @@ def err_module_
diff erent_modmap : Error<
"module '%0' %select{uses|does not use}1 additional module map '%2'"
"%select{| not}1 used when the module was built">;
-def err_pch_macro_def_undef : Error<
- "macro '%0' was %select{defined|undef'd}1 in the precompiled header but "
+def err_ast_file_macro_def_undef : Error<
+ "macro '%0' was %select{defined|undef'd}1 in the AST file '%2' but "
"%select{undef'd|defined}1 on the command line">;
-def err_pch_macro_def_conflict : Error<
- "definition of macro '%0'
diff ers between the precompiled header ('%1') "
+def err_ast_file_macro_def_conflict : Error<
+ "definition of macro '%0'
diff ers between the AST file '%3' ('%1') "
"and the command line ('%2')">;
-def err_pch_undef : Error<
- "%select{command line contains|precompiled header was built with}0 "
- "'-undef' but %select{precompiled header was not built with it|"
+def err_ast_file_undef : Error<
+ "%select{command line contains|AST file '%1' was built with}0 "
+ "'-undef' but %select{AST file '%1' was not built with it|"
"it is not present on the command line}0">;
-def err_pch_pp_detailed_record : Error<
- "%select{command line contains|precompiled header was built with}0 "
- "'-detailed-preprocessing-record' but %select{precompiled header was not "
+def err_ast_file_pp_detailed_record : Error<
+ "%select{command line contains|AST file '%1' was built with}0 "
+ "'-detailed-preprocessing-record' but %select{AST file '%1' was not "
"built with it|it is not present on the command line}0">;
def err_module_odr_violation_missing_decl : Error<
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 6e4b0ec3d27c1b..db93fbd703260d 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -130,6 +130,7 @@ class ASTReaderListener {
///
/// \returns true to indicate the options are invalid or false otherwise.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename,
bool Complain,
bool AllowCompatibleDifferences) {
return false;
@@ -139,7 +140,7 @@ class ASTReaderListener {
///
/// \returns true to indicate the target options are invalid, or false
/// otherwise.
- virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) {
return false;
}
@@ -150,6 +151,7 @@ class ASTReaderListener {
/// otherwise.
virtual bool
ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
+ StringRef ModuleFilename,
bool Complain) {
return false;
}
@@ -172,6 +174,7 @@ class ASTReaderListener {
/// \returns true to indicate the header search options are invalid, or false
/// otherwise.
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) {
return false;
@@ -200,6 +203,7 @@ class ASTReaderListener {
/// \returns true to indicate the preprocessor options are invalid, or false
/// otherwise.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) {
return false;
@@ -262,19 +266,22 @@ class ChainedASTReaderListener : public ASTReaderListener {
bool ReadFullVersionInformation(StringRef FullVersion) override;
void ReadModuleName(StringRef ModuleName) override;
void ReadModuleMapFile(StringRef ModuleMapPath) override;
- bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
+ StringRef ModuleFilename,
bool Complain) override;
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
bool Complain) override;
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override;
@@ -299,16 +306,19 @@ class PCHValidator : public ASTReaderListener {
PCHValidator(Preprocessor &PP, ASTReader &Reader)
: PP(PP), Reader(Reader) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
+ StringRef ModuleFilename,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override;
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override;
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
@@ -325,6 +335,7 @@ class SimpleASTReaderListener : public ASTReaderListener {
SimpleASTReaderListener(Preprocessor &PP) : PP(PP) {}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override;
};
@@ -1367,7 +1378,7 @@ class ASTReader
const ModuleFile *ImportedBy,
unsigned ClientLoadCapabilities);
static ASTReadResult ReadOptionsBlock(
- llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
+ llvm::BitstreamCursor &Stream, StringRef Filename, unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
std::string &SuggestedPredefines);
@@ -1380,6 +1391,7 @@ class ASTReader
static ASTReadResult
readUnhashedControlBlockImpl(ModuleFile *F, llvm::StringRef StreamData,
+ StringRef Filename,
unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch,
ASTReaderListener *Listener,
@@ -1396,21 +1408,21 @@ class ASTReader
unsigned ClientLoadCapabilities);
llvm::Error ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities);
- static bool ParseLanguageOptions(const RecordData &Record, bool Complain,
+ static bool ParseLanguageOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseTargetOptions(const RecordData &Record, bool Complain,
+ static bool ParseTargetOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain,
+ static bool ParseDiagnosticOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener);
static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
ASTReaderListener &Listener);
- static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain,
+ static bool ParseHeaderSearchOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener);
static bool ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
ASTReaderListener &Listener);
- static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain,
+ static bool ParsePreprocessorOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
std::string &SuggestedPredefines);
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 67d4c07d1ce39a..aec1402d6cb95b 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -536,7 +536,7 @@ class ASTInfoCollector : public ASTReaderListener {
LangOpt(LangOpt), TargetOpts(TargetOpts), Target(Target),
Counter(Counter) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
if (InitializedLanguage)
return false;
@@ -559,6 +559,7 @@ class ASTInfoCollector : public ASTReaderListener {
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override {
// llvm::SaveAndRestore doesn't support bit field.
@@ -597,13 +598,14 @@ class ASTInfoCollector : public ASTReaderListener {
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override {
this->PPOpts = PPOpts;
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
// If we've already initialized the target, don't do it again.
if (Target)
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index e70210d55fe28d..f9887fe634ec6c 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -622,7 +622,7 @@ namespace {
Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
}
- bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Language options:\n";
#define LANGOPT(Name, Bits, Default, Description) \
@@ -645,7 +645,7 @@ namespace {
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Target options:\n";
Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
@@ -665,7 +665,7 @@ namespace {
}
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- bool Complain) override {
+ StringRef ModuleFilename, bool Complain) override {
Out.indent(2) << "Diagnostic options:\n";
#define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
@@ -684,6 +684,7 @@ namespace {
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override {
Out.indent(2) << "Header search options:\n";
@@ -717,6 +718,7 @@ namespace {
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override {
Out.indent(2) << "Preprocessor options:\n";
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index e7ccf8a60feb5d..7fbd0ddde2d8a7 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -174,27 +174,28 @@ void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
bool
ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename,
bool Complain,
bool AllowCompatibleDifferences) {
- return First->ReadLanguageOptions(LangOpts, Complain,
+ return First->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
AllowCompatibleDifferences) ||
- Second->ReadLanguageOptions(LangOpts, Complain,
+ Second->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
AllowCompatibleDifferences);
}
bool ChainedASTReaderListener::ReadTargetOptions(
- const TargetOptions &TargetOpts, bool Complain,
+ const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) {
- return First->ReadTargetOptions(TargetOpts, Complain,
+ return First->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
AllowCompatibleDifferences) ||
- Second->ReadTargetOptions(TargetOpts, Complain,
+ Second->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
AllowCompatibleDifferences);
}
bool ChainedASTReaderListener::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, bool Complain) {
- return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
- Second->ReadDiagnosticOptions(DiagOpts, Complain);
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename, bool Complain) {
+ return First->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain) ||
+ Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
bool
@@ -205,20 +206,20 @@ ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
}
bool ChainedASTReaderListener::ReadHeaderSearchOptions(
- const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath,
+ const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef SpecificModuleCachePath,
bool Complain) {
- return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
+ return First->ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
Complain) ||
- Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
+ Second->ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
Complain);
}
bool ChainedASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, bool ReadMacros, bool Complain,
+ const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) {
- return First->ReadPreprocessorOptions(PPOpts, ReadMacros, Complain,
+ return First->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
SuggestedPredefines) ||
- Second->ReadPreprocessorOptions(PPOpts, ReadMacros, Complain,
+ Second->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
SuggestedPredefines);
}
@@ -282,17 +283,17 @@ ASTReaderListener::~ASTReaderListener() = default;
/// \returns true if the languagae options mis-match, false otherwise.
static bool checkLanguageOptions(const LangOptions &LangOpts,
const LangOptions &ExistingLangOpts,
- DiagnosticsEngine *Diags,
+ StringRef ModuleFilename, DiagnosticsEngine *Diags,
bool AllowCompatibleDifferences = true) {
#define LANGOPT(Name, Bits, Default, Description) \
if (ExistingLangOpts.Name != LangOpts.Name) { \
if (Diags) { \
if (Bits == 1) \
- Diags->Report(diag::err_pch_langopt_mismatch) \
- << Description << LangOpts.Name << ExistingLangOpts.Name; \
+ Diags->Report(diag::err_ast_file_langopt_mismatch) \
+ << Description << LangOpts.Name << ExistingLangOpts.Name << ModuleFilename; \
else \
- Diags->Report(diag::err_pch_langopt_value_mismatch) \
- << Description; \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << ModuleFilename; \
} \
return true; \
}
@@ -300,16 +301,16 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
#define VALUE_LANGOPT(Name, Bits, Default, Description) \
if (ExistingLangOpts.Name != LangOpts.Name) { \
if (Diags) \
- Diags->Report(diag::err_pch_langopt_value_mismatch) \
- << Description; \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << ModuleFilename; \
return true; \
}
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
if (Diags) \
- Diags->Report(diag::err_pch_langopt_value_mismatch) \
- << Description; \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << ModuleFilename; \
return true; \
}
@@ -332,22 +333,22 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
if (ExistingLangOpts.ModuleFeatures != LangOpts.ModuleFeatures) {
if (Diags)
- Diags->Report(diag::err_pch_langopt_value_mismatch) << "module features";
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) << "module features" << ModuleFilename;
return true;
}
if (ExistingLangOpts.ObjCRuntime != LangOpts.ObjCRuntime) {
if (Diags)
- Diags->Report(diag::err_pch_langopt_value_mismatch)
- << "target Objective-C runtime";
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch)
+ << "target Objective-C runtime" << ModuleFilename;
return true;
}
if (ExistingLangOpts.CommentOpts.BlockCommandNames !=
LangOpts.CommentOpts.BlockCommandNames) {
if (Diags)
- Diags->Report(diag::err_pch_langopt_value_mismatch)
- << "block command names";
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch)
+ << "block command names" << ModuleFilename;
return true;
}
@@ -369,8 +370,8 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \
bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \
if (InExistingModule != InImportedModule) \
- Diags->Report(diag::err_pch_targetopt_feature_mismatch) \
- << InExistingModule << (Flag + NAME); \
+ Diags->Report(diag::err_ast_file_targetopt_feature_mismatch) \
+ << InExistingModule << ModuleFilename << (Flag + NAME); \
}
#include "clang/Basic/Sanitizers.def"
}
@@ -389,13 +390,13 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
/// \returns true if the target options mis-match, false otherwise.
static bool checkTargetOptions(const TargetOptions &TargetOpts,
const TargetOptions &ExistingTargetOpts,
- DiagnosticsEngine *Diags,
+ StringRef ModuleFilename, DiagnosticsEngine *Diags,
bool AllowCompatibleDifferences = true) {
#define CHECK_TARGET_OPT(Field, Name) \
if (TargetOpts.Field != ExistingTargetOpts.Field) { \
if (Diags) \
- Diags->Report(diag::err_pch_targetopt_mismatch) \
- << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
+ Diags->Report(diag::err_ast_file_targetopt_mismatch) \
+ << ModuleFilename << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
return true; \
}
@@ -439,11 +440,11 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
if (Diags) {
for (StringRef Feature : UnmatchedReadFeatures)
- Diags->Report(diag::err_pch_targetopt_feature_mismatch)
- << /* is-existing-feature */ false << Feature;
+ Diags->Report(diag::err_ast_file_targetopt_feature_mismatch)
+ << /* is-existing-feature */ false << ModuleFilename << Feature;
for (StringRef Feature : UnmatchedExistingFeatures)
- Diags->Report(diag::err_pch_targetopt_feature_mismatch)
- << /* is-existing-feature */ true << Feature;
+ Diags->Report(diag::err_ast_file_targetopt_feature_mismatch)
+ << /* is-existing-feature */ true << ModuleFilename << Feature;
}
return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
@@ -451,19 +452,20 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
bool
PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename,
bool Complain,
bool AllowCompatibleDifferences) {
const LangOptions &ExistingLangOpts = PP.getLangOpts();
- return checkLanguageOptions(LangOpts, ExistingLangOpts,
+ return checkLanguageOptions(LangOpts, ExistingLangOpts, ModuleFilename,
Complain ? &Reader.Diags : nullptr,
AllowCompatibleDifferences);
}
bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts,
- bool Complain,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) {
const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
- return checkTargetOptions(TargetOpts, ExistingTargetOpts,
+ return checkTargetOptions(TargetOpts, ExistingTargetOpts, ModuleFilename,
Complain ? &Reader.Diags : nullptr,
AllowCompatibleDifferences);
}
@@ -478,7 +480,7 @@ using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
DiagnosticsEngine &Diags,
- bool Complain) {
+ StringRef ModuleFilename, bool Complain) {
using Level = DiagnosticsEngine::Level;
// Check current mappings for new -Werror mappings, and the stored mappings
@@ -496,8 +498,8 @@ static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
StoredDiags.getDiagnosticLevel(DiagID, SourceLocation());
if (StoredLevel < DiagnosticsEngine::Error) {
if (Complain)
- Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror=" +
- Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str();
+ Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Werror=" +
+ Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str() << ModuleFilename;
return true;
}
}
@@ -514,7 +516,7 @@ static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags) {
}
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
- DiagnosticsEngine &Diags, bool IsSystem,
+ DiagnosticsEngine &Diags, StringRef ModuleFilename, bool IsSystem,
bool SystemHeaderWarningsInModule,
bool Complain) {
// Top-level options
@@ -526,32 +528,32 @@ static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
if (StoredDiags.getSuppressSystemWarnings() &&
!SystemHeaderWarningsInModule) {
if (Complain)
- Diags.Report(diag::err_pch_diagopt_mismatch) << "-Wsystem-headers";
+ Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Wsystem-headers" << ModuleFilename;
return true;
}
}
if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
if (Complain)
- Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror";
+ Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Werror" << ModuleFilename;
return true;
}
if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
!StoredDiags.getEnableAllWarnings()) {
if (Complain)
- Diags.Report(diag::err_pch_diagopt_mismatch) << "-Weverything -Werror";
+ Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Weverything -Werror" << ModuleFilename;
return true;
}
if (isExtHandlingFromDiagsError(Diags) &&
!isExtHandlingFromDiagsError(StoredDiags)) {
if (Complain)
- Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors";
+ Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-pedantic-errors" << ModuleFilename;
return true;
}
- return checkDiagnosticGroupMappings(StoredDiags, Diags, Complain);
+ return checkDiagnosticGroupMappings(StoredDiags, Diags, ModuleFilename, Complain);
}
/// Return the top import module if it is implicit, nullptr otherwise.
@@ -580,7 +582,7 @@ static Module *getTopImportImplicitModule(ModuleManager &ModuleMgr,
}
bool PCHValidator::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, bool Complain) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename, bool Complain) {
DiagnosticsEngine &ExistingDiags = PP.getDiagnostics();
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(ExistingDiags.getDiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
@@ -605,7 +607,7 @@ bool PCHValidator::ReadDiagnosticOptions(
// FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
// contains the union of their flags.
- return checkDiagnosticMappings(*Diags, ExistingDiags, TopM->IsSystem,
+ return checkDiagnosticMappings(*Diags, ExistingDiags, ModuleFilename, TopM->IsSystem,
SystemHeaderWarningsInModule, Complain);
}
@@ -665,7 +667,7 @@ enum OptionValidation {
/// are no
diff erences in the options between the two.
static bool checkPreprocessorOptions(
const PreprocessorOptions &PPOpts,
- const PreprocessorOptions &ExistingPPOpts, bool ReadMacros,
+ const PreprocessorOptions &ExistingPPOpts, StringRef ModuleFilename, bool ReadMacros,
DiagnosticsEngine *Diags, FileManager &FileMgr,
std::string &SuggestedPredefines, const LangOptions &LangOpts,
OptionValidation Validation = OptionValidateContradictions) {
@@ -695,7 +697,7 @@ static bool checkPreprocessorOptions(
// If strict matches are requested, don't tolerate any extra defines
// on the command line that are missing in the AST file.
if (Diags) {
- Diags->Report(diag::err_pch_macro_def_undef) << MacroName << true;
+ Diags->Report(diag::err_ast_file_macro_def_undef) << MacroName << true << ModuleFilename;
}
return true;
}
@@ -721,8 +723,8 @@ static bool checkPreprocessorOptions(
// conflict.
if (Existing.second != Known->second.second) {
if (Diags) {
- Diags->Report(diag::err_pch_macro_def_undef)
- << MacroName << Known->second.second;
+ Diags->Report(diag::err_ast_file_macro_def_undef)
+ << MacroName << Known->second.second << ModuleFilename;
}
return true;
}
@@ -736,8 +738,8 @@ static bool checkPreprocessorOptions(
// The macro bodies
diff er; complain.
if (Diags) {
- Diags->Report(diag::err_pch_macro_def_conflict)
- << MacroName << Known->second.first << Existing.first;
+ Diags->Report(diag::err_ast_file_macro_def_conflict)
+ << MacroName << Known->second.first << Existing.first << ModuleFilename;
}
return true;
}
@@ -750,7 +752,7 @@ static bool checkPreprocessorOptions(
// the AST file that are missing on the command line.
for (const auto &MacroName : ASTFileMacros.keys()) {
if (Diags) {
- Diags->Report(diag::err_pch_macro_def_undef) << MacroName << false;
+ Diags->Report(diag::err_ast_file_macro_def_undef) << MacroName << false << ModuleFilename;
}
return true;
}
@@ -761,7 +763,7 @@ static bool checkPreprocessorOptions(
if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines;
+ Diags->Report(diag::err_ast_file_undef) << ExistingPPOpts.UsePredefines << ModuleFilename;
}
return true;
}
@@ -771,7 +773,7 @@ static bool checkPreprocessorOptions(
PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord;
+ Diags->Report(diag::err_ast_file_pp_detailed_record) << PPOpts.DetailedRecord << ModuleFilename;
}
return true;
}
@@ -815,19 +817,19 @@ static bool checkPreprocessorOptions(
}
bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) {
const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts();
return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ReadMacros, Complain ? &Reader.Diags : nullptr,
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, Complain ? &Reader.Diags : nullptr,
PP.getFileManager(), SuggestedPredefines, PP.getLangOpts());
}
bool SimpleASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, bool ReadMacros, bool Complain,
+ const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) {
- return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), ReadMacros,
+ return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), ModuleFilename, ReadMacros,
nullptr, PP.getFileManager(),
SuggestedPredefines, PP.getLangOpts(),
OptionValidateNone);
@@ -840,7 +842,7 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
static bool checkModuleCachePath(llvm::vfs::FileSystem &VFS,
StringRef SpecificModuleCachePath,
StringRef ExistingModuleCachePath,
- DiagnosticsEngine *Diags,
+ StringRef ModuleFilename, DiagnosticsEngine *Diags,
const LangOptions &LangOpts,
const PreprocessorOptions &PPOpts) {
if (!LangOpts.Modules || PPOpts.AllowPCHWithDifferentModulesCachePath ||
@@ -851,18 +853,19 @@ static bool checkModuleCachePath(llvm::vfs::FileSystem &VFS,
if (EqualOrErr && *EqualOrErr)
return false;
if (Diags)
- Diags->Report(diag::err_pch_modulecache_mismatch)
- << SpecificModuleCachePath << ExistingModuleCachePath;
+ Diags->Report(diag::err_ast_file_modulecache_mismatch)
+ << SpecificModuleCachePath << ExistingModuleCachePath << ModuleFilename;
return true;
}
bool PCHValidator::ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) {
return checkModuleCachePath(Reader.getFileManager().getVirtualFileSystem(),
SpecificModuleCachePath,
PP.getHeaderSearchInfo().getModuleCachePath(),
- Complain ? &Reader.Diags : nullptr,
+ ModuleFilename, Complain ? &Reader.Diags : nullptr,
PP.getLangOpts(), PP.getPreprocessorOpts());
}
@@ -2761,7 +2764,7 @@ static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
}
ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
- BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
+ BitstreamCursor &Stream, StringRef Filename, unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
std::string &SuggestedPredefines) {
if (llvm::Error Err = Stream.EnterSubBlock(OPTIONS_BLOCK_ID)) {
@@ -2806,7 +2809,7 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
switch ((OptionsRecordTypes)MaybeRecordType.get()) {
case LANGUAGE_OPTIONS: {
bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
- if (ParseLanguageOptions(Record, Complain, Listener,
+ if (ParseLanguageOptions(Record, Filename, Complain, Listener,
AllowCompatibleConfigurationMismatch))
Result = ConfigurationMismatch;
break;
@@ -2814,7 +2817,7 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
case TARGET_OPTIONS: {
bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
- if (ParseTargetOptions(Record, Complain, Listener,
+ if (ParseTargetOptions(Record, Filename, Complain, Listener,
AllowCompatibleConfigurationMismatch))
Result = ConfigurationMismatch;
break;
@@ -2831,7 +2834,7 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
case HEADER_SEARCH_OPTIONS: {
bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
if (!AllowCompatibleConfigurationMismatch &&
- ParseHeaderSearchOptions(Record, Complain, Listener))
+ ParseHeaderSearchOptions(Record, Filename, Complain, Listener))
Result = ConfigurationMismatch;
break;
}
@@ -2839,7 +2842,7 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
case PREPROCESSOR_OPTIONS:
bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
if (!AllowCompatibleConfigurationMismatch &&
- ParsePreprocessorOptions(Record, Complain, Listener,
+ ParsePreprocessorOptions(Record, Filename, Complain, Listener,
SuggestedPredefines))
Result = ConfigurationMismatch;
break;
@@ -2976,7 +2979,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule;
ASTReadResult Result =
- ReadOptionsBlock(Stream, ClientLoadCapabilities,
+ ReadOptionsBlock(Stream, F.FileName, ClientLoadCapabilities,
AllowCompatibleConfigurationMismatch, *Listener,
SuggestedPredefines);
if (Result == Failure) {
@@ -4872,7 +4875,7 @@ ASTReader::readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
bool DisableValidation = shouldDisableValidationForFile(F);
ASTReadResult Result = readUnhashedControlBlockImpl(
- &F, F.Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
+ &F, F.Data, F.FileName, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
Listener.get(),
WasImportedBy ? false : HSOpts.ModulesValidateDiagnosticOptions);
@@ -4916,7 +4919,7 @@ ASTReader::readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
}
ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
- ModuleFile *F, llvm::StringRef StreamData, unsigned ClientLoadCapabilities,
+ ModuleFile *F, llvm::StringRef StreamData, StringRef Filename, unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch, ASTReaderListener *Listener,
bool ValidateDiagnosticOptions) {
// Initialize a stream.
@@ -4986,7 +4989,7 @@ ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
if (Listener && ValidateDiagnosticOptions &&
!AllowCompatibleConfigurationMismatch &&
- ParseDiagnosticOptions(Record, Complain, *Listener))
+ ParseDiagnosticOptions(Record, Filename, Complain, *Listener))
Result = OutOfDate; // Don't return early. Read the signature.
break;
}
@@ -5373,31 +5376,33 @@ namespace {
ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
StrictOptionMatches(StrictOptionMatches) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkLanguageOptions(ExistingLangOpts, LangOpts, nullptr,
+ return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename, nullptr,
AllowCompatibleDifferences);
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkTargetOptions(ExistingTargetOpts, TargetOpts, nullptr,
+ return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename, nullptr,
AllowCompatibleDifferences);
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override {
return checkModuleCachePath(
FileMgr.getVirtualFileSystem(), SpecificModuleCachePath,
- ExistingModuleCachePath, nullptr, ExistingLangOpts, ExistingPPOpts);
+ ExistingModuleCachePath, ModuleFilename, nullptr, ExistingLangOpts, ExistingPPOpts);
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override {
return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ReadMacros, /*Diags=*/nullptr, FileMgr,
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr, FileMgr,
SuggestedPredefines, ExistingLangOpts,
StrictOptionMatches ? OptionValidateStrictMatches
: OptionValidateContradictions);
@@ -5466,7 +5471,7 @@ bool ASTReader::readASTFileControlBlock(
switch (Entry.ID) {
case OPTIONS_BLOCK_ID: {
std::string IgnoredSuggestedPredefines;
- if (ReadOptionsBlock(Stream, ClientLoadCapabilities,
+ if (ReadOptionsBlock(Stream, Filename, ClientLoadCapabilities,
/*AllowCompatibleConfigurationMismatch*/ false,
Listener, IgnoredSuggestedPredefines) != Success)
return true;
@@ -5692,7 +5697,7 @@ bool ASTReader::readASTFileControlBlock(
// Scan for the UNHASHED_CONTROL_BLOCK_ID block.
if (readUnhashedControlBlockImpl(
- nullptr, Bytes, ClientLoadCapabilities,
+ nullptr, Bytes, Filename, ClientLoadCapabilities,
/*AllowCompatibleConfigurationMismatch*/ false, &Listener,
ValidateDiagnosticOptions) != Success)
return true;
@@ -6033,7 +6038,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
///
/// \returns true if the listener deems the file unacceptable, false otherwise.
bool ASTReader::ParseLanguageOptions(const RecordData &Record,
- bool Complain,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences) {
LangOptions LangOpts;
@@ -6070,11 +6075,11 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
LangOpts.OMPHostIRFile = ReadString(Record, Idx);
- return Listener.ReadLanguageOptions(LangOpts, Complain,
+ return Listener.ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
AllowCompatibleDifferences);
}
-bool ASTReader::ParseTargetOptions(const RecordData &Record, bool Complain,
+bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences) {
unsigned Idx = 0;
@@ -6090,11 +6095,11 @@ bool ASTReader::ParseTargetOptions(const RecordData &Record, bool Complain,
TargetOpts.Features.push_back(ReadString(Record, Idx));
}
- return Listener.ReadTargetOptions(TargetOpts, Complain,
+ return Listener.ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
AllowCompatibleDifferences);
}
-bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, bool Complain,
+bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
unsigned Idx = 0;
@@ -6108,7 +6113,7 @@ bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, bool Complain,
for (unsigned N = Record[Idx++]; N; --N)
DiagOpts->Remarks.push_back(ReadString(Record, Idx));
- return Listener.ReadDiagnosticOptions(DiagOpts, Complain);
+ return Listener.ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
bool ASTReader::ParseFileSystemOptions(const RecordData &Record, bool Complain,
@@ -6120,7 +6125,7 @@ bool ASTReader::ParseFileSystemOptions(const RecordData &Record, bool Complain,
}
bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
- bool Complain,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener) {
HeaderSearchOptions HSOpts;
unsigned Idx = 0;
@@ -6139,7 +6144,7 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
HSOpts.UseLibcxx = Record[Idx++];
std::string SpecificModuleCachePath = ReadString(Record, Idx);
- return Listener.ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
+ return Listener.ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
Complain);
}
@@ -6176,7 +6181,7 @@ bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
}
bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
- bool Complain,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
std::string &SuggestedPredefines) {
PreprocessorOptions PPOpts;
@@ -6208,7 +6213,7 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
PPOpts.ObjCXXARCStandardLibrary =
static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
SuggestedPredefines.clear();
- return Listener.ReadPreprocessorOptions(PPOpts, ReadMacros, Complain,
+ return Listener.ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
SuggestedPredefines);
}
diff --git a/clang/test/Modules/check-for-sanitizer-feature.cpp b/clang/test/Modules/check-for-sanitizer-feature.cpp
index 2137b1bf36bb84..861b571f0efaa0 100644
--- a/clang/test/Modules/check-for-sanitizer-feature.cpp
+++ b/clang/test/Modules/check-for-sanitizer-feature.cpp
@@ -43,7 +43,7 @@
//
// Import the PCH without ASan enabled (we expect an error).
// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
-// PCH_MISMATCH: AST file was compiled with the target feature '-fsanitize=address' but the current translation unit is not
+// PCH_MISMATCH: AST file '{{.*}}.asan_pch' was compiled with the target feature '-fsanitize=address' but the current translation unit is not
//
// Emit a PCH with UBSan enabled.
// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
diff --git a/clang/test/Modules/ignored_macros.m b/clang/test/Modules/ignored_macros.m
index a87a11f89c314f..33801dfa4f4767 100644
--- a/clang/test/Modules/ignored_macros.m
+++ b/clang/test/Modules/ignored_macros.m
@@ -10,7 +10,7 @@
// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
// RUN: not %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch %s > %t.err 2>&1
// RUN: FileCheck -check-prefix=CHECK-CONFLICT %s < %t.err
-// CHECK-CONFLICT: PCH was compiled with module cache path
+// CHECK-CONFLICT: AST file '{{.*}}' was compiled with module cache path
// Third trial: pass -DIGNORED=1 only to the second invocation, but
// make it ignored. There should be no failure, IGNORED is defined in
diff --git a/clang/test/Modules/load_failure.c b/clang/test/Modules/load_failure.c
index 3a8d29597348da..662b39b6f1874f 100644
--- a/clang/test/Modules/load_failure.c
+++ b/clang/test/Modules/load_failure.c
@@ -15,7 +15,7 @@
// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
// FIXME: Clean up diagnostic text below and give it a location
-// CHECK-FAILURE: error: C99 was disabled in PCH file but is currently enabled
+// CHECK-FAILURE: error: C99 was disabled in AST file '{{.*}}load_failure.pcm' but is currently enabled
// FIXME: When we have a syntax for modules in C, use that.
diff --git a/clang/test/Modules/merge-target-features.cpp b/clang/test/Modules/merge-target-features.cpp
index 6a29c2db8a8d9e..cc2bbfa077e985 100644
--- a/clang/test/Modules/merge-target-features.cpp
+++ b/clang/test/Modules/merge-target-features.cpp
@@ -20,7 +20,7 @@
// RUN: -target-cpu i386 \
// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \
// RUN: | FileCheck --check-prefix=SUBSET --implicit-check-not=error: %s
-// SUBSET: error: AST file was compiled with the target feature '+sse2' but the current translation unit is not
+// SUBSET: error: AST file '{{.*}}foo.pcm' was compiled with the target feature '+sse2' but the current translation unit is not
// SUBSET: error: {{.*}} configuration mismatch
//
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
@@ -57,8 +57,8 @@
// RUN: -target-cpu i386 -target-feature +cx16 \
// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \
// RUN: | FileCheck --check-prefix=MISMATCH --implicit-check-not=error: %s
-// MISMATCH: error: AST file was compiled with the target feature '+sse2' but the current translation unit is not
-// MISMATCH: error: current translation unit is compiled with the target feature '+cx16' but the AST file was not
+// MISMATCH: error: AST file '{{.*}}foo.pcm' was compiled with the target feature '+sse2' but the current translation unit is not
+// MISMATCH: error: current translation unit is compiled with the target feature '+cx16' but the AST file '{{.*}}foo.pcm' was not
// MISMATCH: error: {{.*}} configuration mismatch
#include "foo.h"
diff --git a/clang/test/Modules/mismatch-diagnostics.cpp b/clang/test/Modules/mismatch-diagnostics.cpp
index 5a026aa1f6c020..dffd4b46a678e5 100644
--- a/clang/test/Modules/mismatch-diagnostics.cpp
+++ b/clang/test/Modules/mismatch-diagnostics.cpp
@@ -29,5 +29,5 @@ export module mismatching_module;
//--- use.cpp
import mismatching_module;
-// CHECK: error: POSIX thread support was enabled in PCH file but is currently disabled
+// CHECK: error: POSIX thread support was enabled in AST file '{{.*[/|\\\\]}}mismatching_module.pcm' but is currently disabled
// CHECK-NEXT: module file {{.*[/|\\\\]}}mismatching_module.pcm cannot be loaded due to a configuration mismatch with the current compilation
diff --git a/clang/test/Modules/module-pch-
diff erent-cache-path.c b/clang/test/Modules/module-pch-
diff erent-cache-path.c
index 8778adc886f719..8dd04a166eab62 100644
--- a/clang/test/Modules/module-pch-
diff erent-cache-path.c
+++ b/clang/test/Modules/module-pch-
diff erent-cache-path.c
@@ -14,5 +14,5 @@
pch_int x = 0;
-// CHECK-ERROR: PCH was compiled with module cache path '{{.*}}', but the path is currently '{{.*}}'
-// CHECK-SUCCESS-NOT: PCH was compiled with module cache path '{{.*}}', but the path is currently '{{.*}}'
+// CHECK-ERROR: AST file '{{.*}}' was compiled with module cache path '{{.*}}', but the path is currently '{{.*}}'
+// CHECK-SUCCESS-NOT: AST file '{{.*}}' was compiled with module cache path '{{.*}}', but the path is currently '{{.*}}'
diff --git a/clang/test/Modules/pr62359.cppm b/clang/test/Modules/pr62359.cppm
index 69acc3ce303a57..7d9d3eec26cca7 100644
--- a/clang/test/Modules/pr62359.cppm
+++ b/clang/test/Modules/pr62359.cppm
@@ -43,7 +43,7 @@ int use() {
return 0;
}
-// CHECK: OpenMP{{.*}}
diff ers in PCH file vs. current file
+// CHECK: OpenMP{{.*}}
diff ers in AST file '{{.*}}Hello.pcm' vs. current file
//--- use2.cpp
// expected-no-diagnostics
@@ -55,5 +55,5 @@ int use2() {
return 0;
}
-// CHECK: OpenMP{{.*}}
diff ers in PCH file vs. current file
+// CHECK: OpenMP{{.*}}
diff ers in AST file '{{.*}}Hello.pcm' vs. current file
// CHECK: use of undeclared identifier 'pragma'
diff --git a/clang/test/PCH/arc.m b/clang/test/PCH/arc.m
index 32069e2314164c..e4ad71a469b956 100644
--- a/clang/test/PCH/arc.m
+++ b/clang/test/PCH/arc.m
@@ -14,5 +14,5 @@
array0 a0;
array1 a1;
-// CHECK-ERR1: Objective-C automated reference counting was enabled in PCH file but is currently disabled
-// CHECK-ERR2: Objective-C automated reference counting was disabled in PCH file but is currently enabled
+// CHECK-ERR1: Objective-C automated reference counting was enabled in AST file '{{.*}}' but is currently disabled
+// CHECK-ERR2: Objective-C automated reference counting was disabled in AST file '{{.*}}' but is currently enabled
diff --git a/clang/test/PCH/fuzzy-pch.c b/clang/test/PCH/fuzzy-pch.c
index 7296d1dc893b3b..53985866dc08ed 100644
--- a/clang/test/PCH/fuzzy-pch.c
+++ b/clang/test/PCH/fuzzy-pch.c
@@ -24,8 +24,8 @@ BAR bar = 17;
# error BAR was not defined
#endif
-// CHECK-FOO: definition of macro 'FOO'
diff ers between the precompiled header ('1') and the command line ('blah')
-// CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
+// CHECK-FOO: definition of macro 'FOO'
diff ers between the AST file '{{.*}}' ('1') and the command line ('blah')
+// CHECK-NOFOO: macro 'FOO' was defined in the AST file '{{.*}}' but undef'd on the command line
-// CHECK-UNDEF: command line contains '-undef' but precompiled header was not built with it
+// CHECK-UNDEF: command line contains '-undef' but AST file '{{.*}}' was not built with it
diff --git a/clang/test/PCH/module-hash-
diff erence.m b/clang/test/PCH/module-hash-
diff erence.m
index fc542b0e8d1ad1..73cf536f88b4f1 100644
--- a/clang/test/PCH/module-hash-
diff erence.m
+++ b/clang/test/PCH/module-hash-
diff erence.m
@@ -4,5 +4,5 @@
// RUN: not %clang_cc1 -fsyntax-only -include-pch %t.pch %s -I %S/Inputs/modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash 2> %t.err
// RUN: FileCheck -input-file=%t.err %s
-// CHECK: error: PCH was compiled with module cache path {{.*}}, but the path is currently {{.*}}
+// CHECK: error: AST file '{{.*}}' was compiled with module cache path {{.*}}, but the path is currently {{.*}}
@import Foo;
diff --git a/clang/test/PCH/ms-pch-macro.c b/clang/test/PCH/ms-pch-macro.c
index a512e66e248668..4d4900cc4f90dc 100644
--- a/clang/test/PCH/ms-pch-macro.c
+++ b/clang/test/PCH/ms-pch-macro.c
@@ -33,7 +33,7 @@ BAR bar = 17;
# error BAR was not defined
#endif
-// CHECK-FOO: definition of macro 'FOO'
diff ers between the precompiled header ('1') and the command line ('blah')
-// CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
+// CHECK-FOO: definition of macro 'FOO'
diff ers between the AST file '{{.*}}1.pch' ('1') and the command line ('blah')
+// CHECK-NOFOO: macro 'FOO' was defined in the AST file '{{.*}}1.pch' but undef'd on the command line
// expected-warning at 2 {{definition of macro 'BAR' does not match definition in precompiled header}}
diff --git a/clang/test/PCH/no-validate-pch.cl b/clang/test/PCH/no-validate-pch.cl
index 26c5fd5cc04c2c..aa228ee2052192 100644
--- a/clang/test/PCH/no-validate-pch.cl
+++ b/clang/test/PCH/no-validate-pch.cl
@@ -16,8 +16,8 @@
// CHECK: note: previous definition is here
// CHECK: #define X 4
-// CHECK-VAL: error: __OPTIMIZE__ predefined macro was enabled in PCH file but is currently disabled
-// CHECK-VAL: error: definition of macro 'X'
diff ers between the precompiled header ('4') and the command line ('5')
+// CHECK-VAL: error: __OPTIMIZE__ predefined macro was enabled in AST file '{{.*}}' but is currently disabled
+// CHECK-VAL: error: definition of macro 'X'
diff ers between the AST file '{{.*}}' ('4') and the command line ('5')
void test(void) {
int a = ONE;
More information about the cfe-commits
mailing list