[clang] 4357175 - [re-format][Modules] Follow-up formatting to "Mention which AST file's options differ from the current TU options." (#102484)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 07:59:51 PDT 2024
Author: Volodymyr Sapsai
Date: 2024-08-08T11:59:47-03:00
New Revision: 435717556908a79748de22c21e3a0ee06a933036
URL: https://github.com/llvm/llvm-project/commit/435717556908a79748de22c21e3a0ee06a933036
DIFF: https://github.com/llvm/llvm-project/commit/435717556908a79748de22c21e3a0ee06a933036.diff
LOG: [re-format][Modules] Follow-up formatting to "Mention which AST file's options differ from the current TU options." (#102484)
Fix formatting for fdf8e3e31103bc81917cdb27150877f524bb2669.
Added:
Modified:
clang/include/clang/Serialization/ASTReader.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Serialization/ASTReader.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index db93fbd703260..549396a3b6b38 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -130,8 +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,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) {
return false;
}
@@ -140,7 +139,8 @@ class ASTReaderListener {
///
/// \returns true to indicate the target options are invalid, or false
/// otherwise.
- virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
+ virtual bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) {
return false;
}
@@ -151,8 +151,7 @@ class ASTReaderListener {
/// otherwise.
virtual bool
ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef ModuleFilename,
- bool Complain) {
+ StringRef ModuleFilename, bool Complain) {
return false;
}
@@ -266,13 +265,14 @@ class ChainedASTReaderListener : public ASTReaderListener {
bool ReadFullVersionInformation(StringRef FullVersion) override;
void ReadModuleName(StringRef ModuleName) override;
void ReadModuleMapFile(StringRef ModuleMapPath) override;
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef ModuleFilename,
- bool Complain) override;
+ StringRef ModuleFilename, bool Complain) override;
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
bool Complain) override;
@@ -281,8 +281,8 @@ class ChainedASTReaderListener : public ASTReaderListener {
StringRef SpecificModuleCachePath,
bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
@@ -306,16 +306,17 @@ class PCHValidator : public ASTReaderListener {
PCHValidator(Preprocessor &PP, ASTReader &Reader)
: PP(PP), Reader(Reader) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override;
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef ModuleFilename,
- bool Complain) override;
+ StringRef ModuleFilename, bool Complain) override;
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef ModuleFilename,
@@ -335,8 +336,8 @@ class SimpleASTReaderListener : public ASTReaderListener {
SimpleASTReaderListener(Preprocessor &PP) : PP(PP) {}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override;
};
@@ -1377,10 +1378,12 @@ class ASTReader
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.
///
@@ -1389,13 +1392,11 @@ class ASTReader
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);
@@ -1408,21 +1409,26 @@ class ASTReader
unsigned ClientLoadCapabilities);
llvm::Error ReadSubmoduleBlock(ModuleFile &F,
unsigned ClientLoadCapabilities);
- static bool ParseLanguageOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
+ static bool ParseLanguageOptions(const RecordData &Record,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseTargetOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
+ static bool ParseTargetOptions(const RecordData &Record,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences);
- static bool ParseDiagnosticOptions(const RecordData &Record, StringRef ModuleFilename, 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, StringRef ModuleFilename, 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, StringRef ModuleFilename, 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 aec1402d6cb95..84e273a3949ef 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -536,7 +536,8 @@ class ASTInfoCollector : public ASTReaderListener {
LangOpt(LangOpt), TargetOpts(TargetOpts), Target(Target),
Counter(Counter) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
if (InitializedLanguage)
return false;
@@ -598,14 +599,15 @@ class ASTInfoCollector : public ASTReaderListener {
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override {
this->PPOpts = PPOpts;
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, 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 f9887fe634ec6..9f5d09e33ce24 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 ModuleFilename, 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 +646,8 @@ namespace {
return false;
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, 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 +667,8 @@ namespace {
}
bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
- StringRef ModuleFilename, 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) \
@@ -718,8 +721,8 @@ namespace {
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, 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 7fbd0ddde2d8a..ad8d6c336f278 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -172,11 +172,9 @@ void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
Second->ReadModuleMapFile(ModuleMapPath);
}
-bool
-ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef ModuleFilename,
- bool Complain,
- bool AllowCompatibleDifferences) {
+bool ChainedASTReaderListener::ReadLanguageOptions(
+ const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
+ bool AllowCompatibleDifferences) {
return First->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
AllowCompatibleDifferences) ||
Second->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
@@ -193,7 +191,8 @@ bool ChainedASTReaderListener::ReadTargetOptions(
}
bool ChainedASTReaderListener::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename, bool Complain) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename,
+ bool Complain) {
return First->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain) ||
Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
@@ -206,21 +205,21 @@ ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
}
bool ChainedASTReaderListener::ReadHeaderSearchOptions(
- const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef SpecificModuleCachePath,
- bool Complain) {
- return First->ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
- Complain) ||
- Second->ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
- Complain);
+ const HeaderSearchOptions &HSOpts, StringRef ModuleFilename,
+ StringRef SpecificModuleCachePath, bool Complain) {
+ return First->ReadHeaderSearchOptions(HSOpts, ModuleFilename,
+ SpecificModuleCachePath, Complain) ||
+ Second->ReadHeaderSearchOptions(HSOpts, ModuleFilename,
+ SpecificModuleCachePath, Complain);
}
bool ChainedASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain,
- std::string &SuggestedPredefines) {
- return First->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
- SuggestedPredefines) ||
- Second->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
- SuggestedPredefines);
+ const PreprocessorOptions &PPOpts, StringRef ModuleFilename,
+ bool ReadMacros, bool Complain, std::string &SuggestedPredefines) {
+ return First->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
+ Complain, SuggestedPredefines) ||
+ Second->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
+ Complain, SuggestedPredefines);
}
void ChainedASTReaderListener::ReadCounter(const serialization::ModuleFile &M,
@@ -283,35 +282,37 @@ ASTReaderListener::~ASTReaderListener() = default;
/// \returns true if the languagae options mis-match, false otherwise.
static bool checkLanguageOptions(const LangOptions &LangOpts,
const LangOptions &ExistingLangOpts,
- StringRef ModuleFilename, 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_ast_file_langopt_mismatch) \
- << Description << LangOpts.Name << ExistingLangOpts.Name << ModuleFilename; \
- else \
- Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
- << Description << ModuleFilename; \
- } \
- 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 << ModuleFilename; \
- 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 << ModuleFilename; \
- 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 \
+ << ModuleFilename; \
+ else \
+ Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
+ << Description << ModuleFilename; \
+ } \
+ 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 << ModuleFilename; \
+ 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 << ModuleFilename; \
+ return true; \
}
#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
@@ -333,14 +334,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" << ModuleFilename;
+ 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_ast_file_langopt_value_mismatch)
- << "target Objective-C runtime" << ModuleFilename;
+ << "target Objective-C runtime" << ModuleFilename;
return true;
}
@@ -348,7 +350,7 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
LangOpts.CommentOpts.BlockCommandNames) {
if (Diags)
Diags->Report(diag::err_ast_file_langopt_value_mismatch)
- << "block command names" << ModuleFilename;
+ << "block command names" << ModuleFilename;
return true;
}
@@ -390,14 +392,16 @@ 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,
- StringRef ModuleFilename, 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_ast_file_targetopt_mismatch) \
- << ModuleFilename << 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) \
+ << ModuleFilename << Name << TargetOpts.Field \
+ << ExistingTargetOpts.Field; \
+ return true; \
}
// The triple and ABI must match exactly.
@@ -450,11 +454,9 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
}
-bool
-PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef ModuleFilename,
- bool Complain,
- bool AllowCompatibleDifferences) {
+bool PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
+ bool AllowCompatibleDifferences) {
const LangOptions &ExistingLangOpts = PP.getLangOpts();
return checkLanguageOptions(LangOpts, ExistingLangOpts, ModuleFilename,
Complain ? &Reader.Diags : nullptr,
@@ -480,7 +482,8 @@ using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
DiagnosticsEngine &Diags,
- StringRef ModuleFilename, bool Complain) {
+ StringRef ModuleFilename,
+ bool Complain) {
using Level = DiagnosticsEngine::Level;
// Check current mappings for new -Werror mappings, and the stored mappings
@@ -498,8 +501,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() << ModuleFilename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Werror=" + Diags.getDiagnosticIDs()
+ ->getWarningOptionForDiag(DiagID)
+ .str()
+ << ModuleFilename;
return true;
}
}
@@ -516,7 +522,8 @@ static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags) {
}
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
- DiagnosticsEngine &Diags, StringRef ModuleFilename, bool IsSystem,
+ DiagnosticsEngine &Diags,
+ StringRef ModuleFilename, bool IsSystem,
bool SystemHeaderWarningsInModule,
bool Complain) {
// Top-level options
@@ -528,32 +535,37 @@ static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
if (StoredDiags.getSuppressSystemWarnings() &&
!SystemHeaderWarningsInModule) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Wsystem-headers" << ModuleFilename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Wsystem-headers" << ModuleFilename;
return true;
}
}
if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-Werror" << ModuleFilename;
+ 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_ast_file_diagopt_mismatch) << "-Weverything -Werror" << ModuleFilename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-Weverything -Werror" << ModuleFilename;
return true;
}
if (isExtHandlingFromDiagsError(Diags) &&
!isExtHandlingFromDiagsError(StoredDiags)) {
if (Complain)
- Diags.Report(diag::err_ast_file_diagopt_mismatch) << "-pedantic-errors" << ModuleFilename;
+ Diags.Report(diag::err_ast_file_diagopt_mismatch)
+ << "-pedantic-errors" << ModuleFilename;
return true;
}
- return checkDiagnosticGroupMappings(StoredDiags, Diags, ModuleFilename, Complain);
+ return checkDiagnosticGroupMappings(StoredDiags, Diags, ModuleFilename,
+ Complain);
}
/// Return the top import module if it is implicit, nullptr otherwise.
@@ -582,7 +594,8 @@ static Module *getTopImportImplicitModule(ModuleManager &ModuleMgr,
}
bool PCHValidator::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename, bool Complain) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename,
+ bool Complain) {
DiagnosticsEngine &ExistingDiags = PP.getDiagnostics();
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(ExistingDiags.getDiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
@@ -607,8 +620,9 @@ bool PCHValidator::ReadDiagnosticOptions(
// FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
// contains the union of their flags.
- return checkDiagnosticMappings(*Diags, ExistingDiags, ModuleFilename, TopM->IsSystem,
- SystemHeaderWarningsInModule, Complain);
+ return checkDiagnosticMappings(*Diags, ExistingDiags, ModuleFilename,
+ TopM->IsSystem, SystemHeaderWarningsInModule,
+ Complain);
}
/// Collect the macro definitions provided by the given preprocessor
@@ -667,8 +681,8 @@ enum OptionValidation {
/// are no
diff erences in the options between the two.
static bool checkPreprocessorOptions(
const PreprocessorOptions &PPOpts,
- const PreprocessorOptions &ExistingPPOpts, StringRef ModuleFilename, bool ReadMacros,
- DiagnosticsEngine *Diags, FileManager &FileMgr,
+ const PreprocessorOptions &ExistingPPOpts, StringRef ModuleFilename,
+ bool ReadMacros, DiagnosticsEngine *Diags, FileManager &FileMgr,
std::string &SuggestedPredefines, const LangOptions &LangOpts,
OptionValidation Validation = OptionValidateContradictions) {
if (ReadMacros) {
@@ -697,7 +711,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 << ModuleFilename;
+ Diags->Report(diag::err_ast_file_macro_def_undef)
+ << MacroName << true << ModuleFilename;
}
return true;
}
@@ -739,7 +754,8 @@ static bool checkPreprocessorOptions(
// The macro bodies
diff er; complain.
if (Diags) {
Diags->Report(diag::err_ast_file_macro_def_conflict)
- << MacroName << Known->second.first << Existing.first << ModuleFilename;
+ << MacroName << Known->second.first << Existing.first
+ << ModuleFilename;
}
return true;
}
@@ -752,7 +768,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 << ModuleFilename;
+ Diags->Report(diag::err_ast_file_macro_def_undef)
+ << MacroName << false << ModuleFilename;
}
return true;
}
@@ -763,7 +780,8 @@ static bool checkPreprocessorOptions(
if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_ast_file_undef) << ExistingPPOpts.UsePredefines << ModuleFilename;
+ Diags->Report(diag::err_ast_file_undef)
+ << ExistingPPOpts.UsePredefines << ModuleFilename;
}
return true;
}
@@ -773,7 +791,8 @@ static bool checkPreprocessorOptions(
PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord &&
Validation != OptionValidateNone) {
if (Diags) {
- Diags->Report(diag::err_ast_file_pp_detailed_record) << PPOpts.DetailedRecord << ModuleFilename;
+ Diags->Report(diag::err_ast_file_pp_detailed_record)
+ << PPOpts.DetailedRecord << ModuleFilename;
}
return true;
}
@@ -817,22 +836,24 @@ static bool checkPreprocessorOptions(
}
bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename, bool ReadMacros, bool Complain,
+ StringRef ModuleFilename,
+ bool ReadMacros, bool Complain,
std::string &SuggestedPredefines) {
const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts();
return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, Complain ? &Reader.Diags : nullptr,
- PP.getFileManager(), SuggestedPredefines, PP.getLangOpts());
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros,
+ Complain ? &Reader.Diags : nullptr, PP.getFileManager(),
+ SuggestedPredefines, PP.getLangOpts());
}
bool SimpleASTReaderListener::ReadPreprocessorOptions(
- const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain,
- std::string &SuggestedPredefines) {
- return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), ModuleFilename, ReadMacros,
- nullptr, PP.getFileManager(),
- SuggestedPredefines, PP.getLangOpts(),
- OptionValidateNone);
+ const PreprocessorOptions &PPOpts, StringRef ModuleFilename,
+ bool ReadMacros, bool Complain, std::string &SuggestedPredefines) {
+ return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(),
+ ModuleFilename, ReadMacros, nullptr,
+ PP.getFileManager(), SuggestedPredefines,
+ PP.getLangOpts(), OptionValidateNone);
}
/// Check that the specified and the existing module cache paths are equivalent.
@@ -842,7 +863,8 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
static bool checkModuleCachePath(llvm::vfs::FileSystem &VFS,
StringRef SpecificModuleCachePath,
StringRef ExistingModuleCachePath,
- StringRef ModuleFilename, DiagnosticsEngine *Diags,
+ StringRef ModuleFilename,
+ DiagnosticsEngine *Diags,
const LangOptions &LangOpts,
const PreprocessorOptions &PPOpts) {
if (!LangOpts.Modules || PPOpts.AllowPCHWithDifferentModulesCachePath ||
@@ -862,11 +884,11 @@ bool PCHValidator::ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef ModuleFilename,
StringRef SpecificModuleCachePath,
bool Complain) {
- return checkModuleCachePath(Reader.getFileManager().getVirtualFileSystem(),
- SpecificModuleCachePath,
- PP.getHeaderSearchInfo().getModuleCachePath(),
- ModuleFilename, Complain ? &Reader.Diags : nullptr,
- PP.getLangOpts(), PP.getPreprocessorOpts());
+ return checkModuleCachePath(
+ Reader.getFileManager().getVirtualFileSystem(), SpecificModuleCachePath,
+ PP.getHeaderSearchInfo().getModuleCachePath(), ModuleFilename,
+ Complain ? &Reader.Diags : nullptr, PP.getLangOpts(),
+ PP.getPreprocessorOpts());
}
void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
@@ -2764,9 +2786,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));
@@ -4875,8 +4897,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
@@ -4919,9 +4941,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);
@@ -5376,34 +5398,37 @@ namespace {
ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
StrictOptionMatches(StrictOptionMatches) {}
- bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename, nullptr,
- AllowCompatibleDifferences);
+ return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename,
+ nullptr, AllowCompatibleDifferences);
}
- bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain,
+ bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename, nullptr,
- AllowCompatibleDifferences);
+ 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, ModuleFilename, nullptr, ExistingLangOpts, ExistingPPOpts);
+ return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
+ SpecificModuleCachePath,
+ ExistingModuleCachePath, ModuleFilename,
+ nullptr, ExistingLangOpts, ExistingPPOpts);
}
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename,
- bool ReadMacros, bool Complain,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
std::string &SuggestedPredefines) override {
return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr, FileMgr,
- SuggestedPredefines, ExistingLangOpts,
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr,
+ FileMgr, SuggestedPredefines, ExistingLangOpts,
StrictOptionMatches ? OptionValidateStrictMatches
: OptionValidateContradictions);
}
@@ -6079,7 +6104,8 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
AllowCompatibleDifferences);
}
-bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
+bool ASTReader::ParseTargetOptions(const RecordData &Record,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener,
bool AllowCompatibleDifferences) {
unsigned Idx = 0;
@@ -6099,7 +6125,8 @@ bool ASTReader::ParseTargetOptions(const RecordData &Record, StringRef ModuleFil
AllowCompatibleDifferences);
}
-bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, StringRef ModuleFilename, bool Complain,
+bool ASTReader::ParseDiagnosticOptions(const RecordData &Record,
+ StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
unsigned Idx = 0;
@@ -6125,7 +6152,8 @@ bool ASTReader::ParseFileSystemOptions(const RecordData &Record, bool Complain,
}
bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
- StringRef ModuleFilename, bool Complain,
+ StringRef ModuleFilename,
+ bool Complain,
ASTReaderListener &Listener) {
HeaderSearchOptions HSOpts;
unsigned Idx = 0;
@@ -6144,8 +6172,8 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
HSOpts.UseLibcxx = Record[Idx++];
std::string SpecificModuleCachePath = ReadString(Record, Idx);
- return Listener.ReadHeaderSearchOptions(HSOpts, ModuleFilename, SpecificModuleCachePath,
- Complain);
+ return Listener.ReadHeaderSearchOptions(HSOpts, ModuleFilename,
+ SpecificModuleCachePath, Complain);
}
bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
@@ -6181,7 +6209,8 @@ bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
}
bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
- StringRef ModuleFilename, bool Complain,
+ StringRef ModuleFilename,
+ bool Complain,
ASTReaderListener &Listener,
std::string &SuggestedPredefines) {
PreprocessorOptions PPOpts;
@@ -6213,8 +6242,8 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
PPOpts.ObjCXXARCStandardLibrary =
static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
SuggestedPredefines.clear();
- return Listener.ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros, Complain,
- SuggestedPredefines);
+ return Listener.ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
+ Complain, SuggestedPredefines);
}
std::pair<ModuleFile *, unsigned>
More information about the cfe-commits
mailing list