[clang] [Modules][Diagnostic] Mention which AST file's options differ from the current TU options. (PR #101413)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 12:50:34 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 30b5d4a76357feebf4797d1d80bc9d5608c74a88 255b7179c9c708355f4217c7f85ea234ac94c59f --extensions h,cppm,cpp,c -- 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/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/fuzzy-pch.c clang/test/PCH/ms-pch-macro.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 7b878554c9..7bbb64c138 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -130,8 +130,7 @@ public:
///
/// \returns true to indicate the options are invalid or false otherwise.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef Filename,
- bool Complain,
+ StringRef Filename, bool Complain,
bool AllowCompatibleDifferences) {
return false;
}
@@ -140,7 +139,8 @@ public:
///
/// \returns true to indicate the target options are invalid, or false
/// otherwise.
- virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ virtual bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef Filename, bool Complain,
bool AllowCompatibleDifferences) {
return false;
}
@@ -151,8 +151,7 @@ public:
/// otherwise.
virtual bool
ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef Filename,
- bool Complain) {
+ StringRef Filename, bool Complain) {
return false;
}
@@ -203,8 +202,8 @@ public:
/// \returns true to indicate the preprocessor options are invalid, or false
/// otherwise.
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) {
return false;
}
@@ -266,13 +265,14 @@ public:
bool ReadFullVersionInformation(StringRef FullVersion) override;
void ReadModuleName(StringRef ModuleName) override;
void ReadModuleMapFile(StringRef ModuleMapPath) override;
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef Filename,
- bool Complain) override;
+ StringRef Filename, bool Complain) override;
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
bool Complain) override;
@@ -281,8 +281,8 @@ public:
StringRef SpecificModuleCachePath,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
@@ -306,16 +306,17 @@ public:
PCHValidator(Preprocessor &PP, ASTReader &Reader)
: PP(PP), Reader(Reader) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef Filename,
- bool Complain) override;
+ StringRef Filename, bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef Filename,
@@ -335,8 +336,8 @@ public:
SimpleASTReaderListener(Preprocessor &PP) : PP(PP) {}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
};
@@ -1372,10 +1373,12 @@ private:
SmallVectorImpl<ImportedModule> &Loaded,
const ModuleFile *ImportedBy,
unsigned ClientLoadCapabilities);
- static ASTReadResult ReadOptionsBlock(
- llvm::BitstreamCursor &Stream, StringRef Filename, unsigned ClientLoadCapabilities,
- bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
- std::string &SuggestedPredefines);
+ static ASTReadResult
+ ReadOptionsBlock(llvm::BitstreamCursor &Stream, StringRef Filename,
+ unsigned ClientLoadCapabilities,
+ bool AllowCompatibleConfigurationMismatch,
+ ASTReaderListener &Listener,
+ std::string &SuggestedPredefines);
/// Read the unhashed control block.
///
@@ -1384,13 +1387,11 @@ private:
ASTReadResult readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
unsigned ClientLoadCapabilities);
- static ASTReadResult
- readUnhashedControlBlockImpl(ModuleFile *F, llvm::StringRef StreamData,
- StringRef Filename,
- unsigned ClientLoadCapabilities,
- bool AllowCompatibleConfigurationMismatch,
- ASTReaderListener *Listener,
- bool ValidateDiagnosticOptions);
+ static ASTReadResult readUnhashedControlBlockImpl(
+ ModuleFile *F, llvm::StringRef StreamData, StringRef Filename,
+ unsigned ClientLoadCapabilities,
+ bool AllowCompatibleConfigurationMismatch, ASTReaderListener *Listener,
+ bool ValidateDiagnosticOptions);
llvm::Error ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
llvm::Error ReadExtensionBlock(ModuleFile &F);
@@ -1403,21 +1404,24 @@ private:
unsigned ClientLoadCapabilities);
llvm::Error ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities);
- static bool ParseLanguageOptions(const RecordData &Record, StringRef Filename, bool Complain,
- ASTReaderListener &Listener,
+ static bool ParseLanguageOptions(const RecordData &Record, StringRef Filename,
+ bool Complain, ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseTargetOptions(const RecordData &Record, StringRef Filename, bool Complain,
- ASTReaderListener &Listener,
+ static bool ParseTargetOptions(const RecordData &Record, StringRef Filename,
+ bool Complain, ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseDiagnosticOptions(const RecordData &Record, StringRef Filename, bool Complain,
+ static bool ParseDiagnosticOptions(const RecordData &Record,
+ StringRef Filename, bool Complain,
ASTReaderListener &Listener);
static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
ASTReaderListener &Listener);
- static bool ParseHeaderSearchOptions(const RecordData &Record, StringRef Filename, bool Complain,
+ static bool ParseHeaderSearchOptions(const RecordData &Record,
+ StringRef Filename, bool Complain,
ASTReaderListener &Listener);
static bool ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
ASTReaderListener &Listener);
- static bool ParsePreprocessorOptions(const RecordData &Record, StringRef Filename, bool Complain,
+ static bool ParsePreprocessorOptions(const RecordData &Record,
+ StringRef Filename, bool Complain,
ASTReaderListener &Listener,
std::string &SuggestedPredefines);
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index ce22268d76..877772cc74 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -536,7 +536,8 @@ public:
LangOpt(LangOpt), TargetOpts(TargetOpts), Target(Target),
Counter(Counter) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override {
if (InitializedLanguage)
return false;
@@ -598,14 +599,15 @@ public:
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override {
this->PPOpts = PPOpts;
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename,
+ 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 164f361ff0..5e5769a6c3 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -622,7 +622,8 @@ namespace {
Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Language options:\n";
#define LANGOPT(Name, Bits, Default, Description) \
@@ -645,7 +646,8 @@ namespace {
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override {
Out.indent(2) << "Target options:\n";
Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
@@ -718,8 +720,8 @@ namespace {
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override {
Out.indent(2) << "Preprocessor options:\n";
DUMP_BOOLEAN(PPOpts.UsePredefines,
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 4d3797a6a2..2aa3fcc036 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -171,11 +171,9 @@ void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
Second->ReadModuleMapFile(ModuleMapPath);
}
-bool
-ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef Filename,
- bool Complain,
- bool AllowCompatibleDifferences) {
+bool ChainedASTReaderListener::ReadLanguageOptions(
+ const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool AllowCompatibleDifferences) {
return First->ReadLanguageOptions(LangOpts, Filename, Complain,
AllowCompatibleDifferences) ||
Second->ReadLanguageOptions(LangOpts, Filename, Complain,
@@ -192,7 +190,8 @@ bool ChainedASTReaderListener::ReadTargetOptions(
}
bool ChainedASTReaderListener::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef Filename, bool Complain) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef Filename,
+ bool Complain) {
return First->ReadDiagnosticOptions(DiagOpts, Filename, Complain) ||
Second->ReadDiagnosticOptions(DiagOpts, Filename, Complain);
}
@@ -205,17 +204,17 @@ ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
}
bool ChainedASTReaderListener::ReadHeaderSearchOptions(
- const HeaderSearchOptions &HSOpts, StringRef Filename, StringRef SpecificModuleCachePath,
- bool Complain) {
- return First->ReadHeaderSearchOptions(HSOpts, Filename, SpecificModuleCachePath,
- Complain) ||
- Second->ReadHeaderSearchOptions(HSOpts, Filename, SpecificModuleCachePath,
- Complain);
+ const HeaderSearchOptions &HSOpts, StringRef Filename,
+ StringRef SpecificModuleCachePath, bool Complain) {
+ return First->ReadHeaderSearchOptions(HSOpts, Filename,
+ SpecificModuleCachePath, Complain) ||
+ Second->ReadHeaderSearchOptions(HSOpts, Filename,
+ SpecificModuleCachePath, Complain);
}
bool ChainedASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, StringRef Filename, bool ReadMacros, bool Complain,
- std::string &SuggestedPredefines) {
+ const PreprocessorOptions &PPOpts, StringRef Filename, bool ReadMacros,
+ bool Complain, std::string &SuggestedPredefines) {
return First->ReadPreprocessorOptions(PPOpts, Filename, ReadMacros, Complain,
SuggestedPredefines) ||
Second->ReadPreprocessorOptions(PPOpts, Filename, ReadMacros, Complain,
@@ -284,33 +283,34 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
const LangOptions &ExistingLangOpts,
StringRef Filename, 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_ast_file_langopt_mismatch) \
- << Description << LangOpts.Name << ExistingLangOpts.Name << Filename; \
- else \
- Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
- << Description << Filename; \
- } \
- return true; \
- }
-
-#define VALUE_LANGOPT(Name, Bits, Default, Description) \
- if (ExistingLangOpts.Name != LangOpts.Name) { \
- if (Diags) \
- Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
- << Description << Filename; \
- return true; \
- }
-
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
- if (Diags) \
- Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
- << Description << Filename; \
- return true; \
+#define LANGOPT(Name, Bits, Default, Description) \
+ if (ExistingLangOpts.Name != LangOpts.Name) { \
+ if (Diags) { \
+ if (Bits == 1) \
+ Diags->Report(diag::err_ast_file_langopt_mismatch) \
+ << Description << LangOpts.Name << ExistingLangOpts.Name \
+ << Filename; \
+ else \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << Filename; \
+ } \
+ return true; \
+ }
+
+#define VALUE_LANGOPT(Name, Bits, Default, Description) \
+ if (ExistingLangOpts.Name != LangOpts.Name) { \
+ if (Diags) \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << Filename; \
+ return true; \
+ }
+
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+ if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
+ if (Diags) \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << Filename; \
+ return true; \
}
#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
@@ -332,14 +332,15 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
if (ExistingLangOpts.ModuleFeatures != LangOpts.ModuleFeatures) {
if (Diags)
- Diags->Report(diag::err_ast_file_langopt_value_mismatch) << "module features" << Filename;
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch)
+ << "module features" << Filename;
return true;
}
if (ExistingLangOpts.ObjCRuntime != LangOpts.ObjCRuntime) {
if (Diags)
Diags->Report(diag::err_ast_file_langopt_value_mismatch)
- << "target Objective-C runtime" << Filename;
+ << "target Objective-C runtime" << Filename;
return true;
}
@@ -347,7 +348,7 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
LangOpts.CommentOpts.BlockCommandNames) {
if (Diags)
Diags->Report(diag::err_ast_file_langopt_value_mismatch)
- << "block command names" << Filename;
+ << "block command names" << Filename;
return true;
}
@@ -391,12 +392,12 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
const TargetOptions &ExistingTargetOpts,
StringRef Filename, DiagnosticsEngine *Diags,
bool AllowCompatibleDifferences = true) {
-#define CHECK_TARGET_OPT(Field, Name) \
- if (TargetOpts.Field != ExistingTargetOpts.Field) { \
- if (Diags) \
- Diags->Report(diag::err_ast_file_targetopt_mismatch) \
- << Filename << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
- return true; \
+#define CHECK_TARGET_OPT(Field, Name) \
+ if (TargetOpts.Field != ExistingTargetOpts.Field) { \
+ if (Diags) \
+ Diags->Report(diag::err_ast_file_targetopt_mismatch) \
+ << Filename << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
+ return true; \
}
// The triple and ABI must match exactly.
@@ -449,11 +450,9 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
}
-bool
-PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef Filename,
- bool Complain,
- bool AllowCompatibleDifferences) {
+bool PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef Filename, bool Complain,
+ bool AllowCompatibleDifferences) {
const LangOptions &ExistingLangOpts = PP.getLangOpts();
return checkLanguageOptions(LangOpts, ExistingLangOpts, Filename,
Complain ? &Reader.Diags : nullptr,
@@ -497,8 +496,11 @@ static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
StoredDiags.getDiagnosticLevel(DiagID, SourceLocation());
if (StoredLevel < DiagnosticsEngine::Error) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Werror=" +
- Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str() << Filename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Werror=" + Diags.getDiagnosticIDs()
+ ->getWarningOptionForDiag(DiagID)
+ .str()
+ << Filename;
return true;
}
}
@@ -515,7 +517,8 @@ static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags) {
}
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
- DiagnosticsEngine &Diags, StringRef Filename, bool IsSystem,
+ DiagnosticsEngine &Diags,
+ StringRef Filename, bool IsSystem,
bool SystemHeaderWarningsInModule,
bool Complain) {
// Top-level options
@@ -527,28 +530,32 @@ static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
if (StoredDiags.getSuppressSystemWarnings() &&
!SystemHeaderWarningsInModule) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Wsystem-headers" << Filename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Wsystem-headers" << Filename;
return true;
}
}
if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Werror" << Filename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Werror" << Filename;
return true;
}
if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
!StoredDiags.getEnableAllWarnings()) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Weverything -Werror" << Filename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Weverything -Werror" << Filename;
return true;
}
if (isExtHandlingFromDiagsError(Diags) &&
!isExtHandlingFromDiagsError(StoredDiags)) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-pedantic-errors" << Filename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-pedantic-errors" << Filename;
return true;
}
@@ -581,7 +588,8 @@ static Module *getTopImportImplicitModule(ModuleManager &ModuleMgr,
}
bool PCHValidator::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef Filename, bool Complain) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef Filename,
+ bool Complain) {
DiagnosticsEngine &ExistingDiags = PP.getDiagnostics();
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(ExistingDiags.getDiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
@@ -606,8 +614,9 @@ bool PCHValidator::ReadDiagnosticOptions(
// FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
// contains the union of their flags.
- return checkDiagnosticMappings(*Diags, ExistingDiags, Filename, TopM->IsSystem,
- SystemHeaderWarningsInModule, Complain);
+ return checkDiagnosticMappings(*Diags, ExistingDiags, Filename,
+ TopM->IsSystem, SystemHeaderWarningsInModule,
+ Complain);
}
/// Collect the macro definitions provided by the given preprocessor
@@ -666,8 +675,8 @@ enum OptionValidation {
/// are no differences in the options between the two.
static bool checkPreprocessorOptions(
const PreprocessorOptions &PPOpts,
- const PreprocessorOptions &ExistingPPOpts, StringRef Filename, bool ReadMacros,
- DiagnosticsEngine *Diags, FileManager &FileMgr,
+ const PreprocessorOptions &ExistingPPOpts, StringRef Filename,
+ bool ReadMacros, DiagnosticsEngine *Diags, FileManager &FileMgr,
std::string &SuggestedPredefines, const LangOptions &LangOpts,
OptionValidation Validation = OptionValidateContradictions) {
if (ReadMacros) {
@@ -696,7 +705,8 @@ 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_ast_file_macro_def_undef) << MacroName << true << Filename;
+ Diags->Report(diag::err_ast_file_macro_def_undef)
+ << MacroName << true << Filename;
}
return true;
}
@@ -751,7 +761,8 @@ 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_ast_file_macro_def_undef) << MacroName << false << Filename;
+ Diags->Report(diag::err_ast_file_macro_def_undef)
+ << MacroName << false << Filename;
}
return true;
}
@@ -762,7 +773,8 @@ static bool checkPreprocessorOptions(
if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_ast_file_undef) << ExistingPPOpts.UsePredefines << Filename;
+ Diags->Report(diag::err_ast_file_undef)
+ << ExistingPPOpts.UsePredefines << Filename;
}
return true;
}
@@ -772,7 +784,8 @@ static bool checkPreprocessorOptions(
PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_ast_file_pp_detailed_record) << PPOpts.DetailedRecord << Filename;
+ Diags->Report(diag::err_ast_file_pp_detailed_record)
+ << PPOpts.DetailedRecord << Filename;
}
return true;
}
@@ -816,20 +829,22 @@ static bool checkPreprocessorOptions(
}
bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename, bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) {
const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts();
- return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, Filename, ReadMacros, Complain ? &Reader.Diags : nullptr,
- PP.getFileManager(), SuggestedPredefines, PP.getLangOpts());
+ return checkPreprocessorOptions(PPOpts, ExistingPPOpts, Filename, ReadMacros,
+ Complain ? &Reader.Diags : nullptr,
+ PP.getFileManager(), SuggestedPredefines,
+ PP.getLangOpts());
}
bool SimpleASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, StringRef Filename, bool ReadMacros, bool Complain,
- std::string &SuggestedPredefines) {
- return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), Filename, ReadMacros,
- nullptr, PP.getFileManager(),
+ const PreprocessorOptions &PPOpts, StringRef Filename, bool ReadMacros,
+ bool Complain, std::string &SuggestedPredefines) {
+ return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), Filename,
+ ReadMacros, nullptr, PP.getFileManager(),
SuggestedPredefines, PP.getLangOpts(),
OptionValidateNone);
}
@@ -2762,9 +2777,9 @@ static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
}
ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
- BitstreamCursor &Stream, StringRef Filename, unsigned ClientLoadCapabilities,
- bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
- std::string &SuggestedPredefines) {
+ BitstreamCursor &Stream, StringRef Filename,
+ unsigned ClientLoadCapabilities, bool AllowCompatibleConfigurationMismatch,
+ ASTReaderListener &Listener, std::string &SuggestedPredefines) {
if (llvm::Error Err = Stream.EnterSubBlock(OPTIONS_BLOCK_ID)) {
// FIXME this drops errors on the floor.
consumeError(std::move(Err));
@@ -4866,8 +4881,8 @@ ASTReader::readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
bool DisableValidation = shouldDisableValidationForFile(F);
ASTReadResult Result = readUnhashedControlBlockImpl(
- &F, F.Data, F.FileName, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
- Listener.get(),
+ &F, F.Data, F.FileName, ClientLoadCapabilities,
+ AllowCompatibleConfigurationMismatch, Listener.get(),
WasImportedBy ? false : HSOpts.ModulesValidateDiagnosticOptions);
// If F was directly imported by another module, it's implicitly validated by
@@ -4910,9 +4925,9 @@ ASTReader::readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
}
ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
- ModuleFile *F, llvm::StringRef StreamData, StringRef Filename, unsigned ClientLoadCapabilities,
- bool AllowCompatibleConfigurationMismatch, ASTReaderListener *Listener,
- bool ValidateDiagnosticOptions) {
+ ModuleFile *F, llvm::StringRef StreamData, StringRef Filename,
+ unsigned ClientLoadCapabilities, bool AllowCompatibleConfigurationMismatch,
+ ASTReaderListener *Listener, bool ValidateDiagnosticOptions) {
// Initialize a stream.
BitstreamCursor Stream(StreamData);
@@ -5367,34 +5382,37 @@ namespace {
ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
StrictOptionMatches(StrictOptionMatches) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override {
return checkLanguageOptions(ExistingLangOpts, LangOpts, Filename, nullptr,
AllowCompatibleDifferences);
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef Filename,
+ bool Complain,
bool AllowCompatibleDifferences) override {
- return checkTargetOptions(ExistingTargetOpts, TargetOpts, Filename, nullptr,
- AllowCompatibleDifferences);
+ return checkTargetOptions(ExistingTargetOpts, TargetOpts, Filename,
+ nullptr, AllowCompatibleDifferences);
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef Filename,
StringRef SpecificModuleCachePath,
bool Complain) override {
- return checkModuleCachePath(
- FileMgr.getVirtualFileSystem(), SpecificModuleCachePath,
- ExistingModuleCachePath, Filename, nullptr, ExistingLangOpts, ExistingPPOpts);
+ return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
+ SpecificModuleCachePath,
+ ExistingModuleCachePath, Filename, nullptr,
+ ExistingLangOpts, ExistingPPOpts);
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef Filename,
- bool ReadMacros, bool Complain,
+ StringRef Filename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override {
return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, Filename, ReadMacros, /*Diags=*/nullptr, FileMgr,
- SuggestedPredefines, ExistingLangOpts,
+ PPOpts, ExistingPPOpts, Filename, ReadMacros, /*Diags=*/nullptr,
+ FileMgr, SuggestedPredefines, ExistingLangOpts,
StrictOptionMatches ? OptionValidateStrictMatches
: OptionValidateContradictions);
}
@@ -6070,8 +6088,8 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
AllowCompatibleDifferences);
}
-bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef Filename, bool Complain,
- ASTReaderListener &Listener,
+bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef Filename,
+ bool Complain, ASTReaderListener &Listener,
bool AllowCompatibleDifferences) {
unsigned Idx = 0;
TargetOptions TargetOpts;
@@ -6090,7 +6108,8 @@ bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef Filename,
AllowCompatibleDifferences);
}
-bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, StringRef Filename, bool Complain,
+bool ASTReader::ParseDiagnosticOptions(const RecordData &Record,
+ StringRef Filename, bool Complain,
ASTReaderListener &Listener) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
unsigned Idx = 0;
@@ -6135,8 +6154,8 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
HSOpts.UseLibcxx = Record[Idx++];
std::string SpecificModuleCachePath = ReadString(Record, Idx);
- return Listener.ReadHeaderSearchOptions(HSOpts, Filename, SpecificModuleCachePath,
- Complain);
+ return Listener.ReadHeaderSearchOptions(HSOpts, Filename,
+ SpecificModuleCachePath, Complain);
}
bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
@@ -6204,8 +6223,8 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
PPOpts.ObjCXXARCStandardLibrary =
static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
SuggestedPredefines.clear();
- return Listener.ReadPreprocessorOptions(PPOpts, Filename, ReadMacros, Complain,
- SuggestedPredefines);
+ return Listener.ReadPreprocessorOptions(PPOpts, Filename, ReadMacros,
+ Complain, SuggestedPredefines);
}
std::pair<ModuleFile *, unsigned>
``````````
</details>
https://github.com/llvm/llvm-project/pull/101413
More information about the cfe-commits
mailing list