@@ -3946,20 +3946,23 @@ const char *DefaultFallbackStyle = "LLVM";
3946
3946
3947
3947
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
3948
3948
loadAndParseConfigFile (StringRef ConfigFile, llvm::vfs::FileSystem *FS,
3949
- FormatStyle *Style, bool AllowUnknownOptions) {
3949
+ FormatStyle *Style, bool AllowUnknownOptions,
3950
+ llvm::SourceMgr::DiagHandlerTy DiagHandler) {
3950
3951
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
3951
3952
FS->getBufferForFile (ConfigFile.str ());
3952
3953
if (auto EC = Text.getError ())
3953
3954
return EC;
3954
- if (auto EC = parseConfiguration (*Text.get (), Style, AllowUnknownOptions))
3955
+ if (auto EC = parseConfiguration (*Text.get (), Style, AllowUnknownOptions,
3956
+ DiagHandler)) {
3955
3957
return EC;
3958
+ }
3956
3959
return Text;
3957
3960
}
3958
3961
3959
- Expected<FormatStyle> getStyle (StringRef StyleName, StringRef FileName,
3960
- StringRef FallbackStyleName , StringRef Code ,
3961
- llvm::vfs::FileSystem *FS,
3962
- bool AllowUnknownOptions ) {
3962
+ Expected<FormatStyle>
3963
+ getStyle (StringRef StyleName, StringRef FileName , StringRef FallbackStyleName ,
3964
+ StringRef Code, llvm::vfs::FileSystem *FS, bool AllowUnknownOptions ,
3965
+ llvm::SourceMgr::DiagHandlerTy DiagHandler ) {
3963
3966
FormatStyle Style = getLLVMStyle (guessLanguage (FileName, Code));
3964
3967
FormatStyle FallbackStyle = getNoStyle ();
3965
3968
if (!getPredefinedStyle (FallbackStyleName, Style.Language , &FallbackStyle))
@@ -3972,7 +3975,7 @@ Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
3972
3975
StringRef Source = " <command-line>" ;
3973
3976
if (std::error_code ec =
3974
3977
parseConfiguration (llvm::MemoryBufferRef (StyleName, Source), &Style,
3975
- AllowUnknownOptions)) {
3978
+ AllowUnknownOptions, DiagHandler )) {
3976
3979
return make_string_error (" Error parsing -style: " + ec.message ());
3977
3980
}
3978
3981
@@ -3992,7 +3995,8 @@ Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
3992
3995
StyleName.starts_with_insensitive (" file:" )) {
3993
3996
auto ConfigFile = StyleName.substr (5 );
3994
3997
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
3995
- loadAndParseConfigFile (ConfigFile, FS, &Style, AllowUnknownOptions);
3998
+ loadAndParseConfigFile (ConfigFile, FS, &Style, AllowUnknownOptions,
3999
+ DiagHandler);
3996
4000
if (auto EC = Text.getError ()) {
3997
4001
return make_string_error (" Error reading " + ConfigFile + " : " +
3998
4002
EC.message ());
@@ -4027,12 +4031,10 @@ Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
4027
4031
// Reset possible inheritance
4028
4032
Style.InheritsParentConfig = false ;
4029
4033
4030
- auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {};
4031
-
4032
4034
auto applyChildFormatTexts = [&](FormatStyle *Style) {
4033
4035
for (const auto &MemBuf : llvm::reverse (ChildFormatTextToApply)) {
4034
4036
auto EC = parseConfiguration (*MemBuf, Style, AllowUnknownOptions,
4035
- dropDiagnosticHandler );
4037
+ DiagHandler );
4036
4038
// It was already correctly parsed.
4037
4039
assert (!EC);
4038
4040
static_cast <void >(EC);
@@ -4066,7 +4068,8 @@ Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
4066
4068
}
4067
4069
4068
4070
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
4069
- loadAndParseConfigFile (ConfigFile, FS, &Style, AllowUnknownOptions);
4071
+ loadAndParseConfigFile (ConfigFile, FS, &Style, AllowUnknownOptions,
4072
+ DiagHandler);
4070
4073
if (auto EC = Text.getError ()) {
4071
4074
if (EC != ParseError::Unsuitable) {
4072
4075
return make_string_error (" Error reading " + ConfigFile + " : " +
0 commit comments