[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
This commit is contained in:
Volodymyr Sapsai
2024-08-08 11:23:47 -03:00
committed by GitHub
parent 2b1122eaec
commit fdf8e3e311
17 changed files with 176 additions and 155 deletions

View File

@@ -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 differs 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 differs 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 different VFS overlay files than are currently in use">,
@@ -99,19 +99,19 @@ def err_module_different_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' differs between the precompiled header ('%1') "
def err_ast_file_macro_def_conflict : Error<
"definition of macro '%0' differs 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<

View File

@@ -130,6 +130,7 @@ public:
///
/// \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 @@ public:
///
/// \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 @@ public:
/// otherwise.
virtual bool
ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
StringRef ModuleFilename,
bool Complain) {
return false;
}
@@ -172,6 +174,7 @@ public:
/// \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 @@ public:
/// \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 @@ public:
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 @@ public:
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 @@ public:
SimpleASTReaderListener(Preprocessor &PP) : PP(PP) {}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
StringRef ModuleFilename,
bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) override;
};
@@ -1367,7 +1378,7 @@ private:
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 @@ private:
static ASTReadResult
readUnhashedControlBlockImpl(ModuleFile *F, llvm::StringRef StreamData,
StringRef Filename,
unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch,
ASTReaderListener *Listener,
@@ -1396,21 +1408,21 @@ private:
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);

View File

@@ -536,7 +536,7 @@ public:
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 @@ public:
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) override {
// llvm::SaveAndRestore doesn't support bit field.
@@ -597,13 +598,14 @@ public:
}
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)

View File

@@ -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";

View File

@@ -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 differences 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 differ; 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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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"

View File

@@ -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

View File

@@ -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 '{{.*}}'

View File

@@ -43,7 +43,7 @@ int use() {
return 0;
}
// CHECK: OpenMP{{.*}}differs in PCH file vs. current file
// CHECK: OpenMP{{.*}}differs in AST file '{{.*}}Hello.pcm' vs. current file
//--- use2.cpp
// expected-no-diagnostics
@@ -55,5 +55,5 @@ int use2() {
return 0;
}
// CHECK: OpenMP{{.*}}differs in PCH file vs. current file
// CHECK: OpenMP{{.*}}differs in AST file '{{.*}}Hello.pcm' vs. current file
// CHECK: use of undeclared identifier 'pragma'

View File

@@ -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

View File

@@ -24,8 +24,8 @@ BAR bar = 17;
# error BAR was not defined
#endif
// CHECK-FOO: definition of macro 'FOO' differs 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' differs 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

View File

@@ -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;

View File

@@ -33,7 +33,7 @@ BAR bar = 17;
# error BAR was not defined
#endif
// CHECK-FOO: definition of macro 'FOO' differs 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' differs 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@2 {{definition of macro 'BAR' does not match definition in precompiled header}}

View File

@@ -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' differs 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' differs between the AST file '{{.*}}' ('4') and the command line ('5')
void test(void) {
int a = ONE;