Skip to content

Commit 11efce4

Browse files
authored
[clang-tidy][NFC] Fix misc-const-correctness warnings (1/N) (#167030)
Start fixing `misc-const-correctness` warning to enable the check in config
1 parent 7f55f26 commit 11efce4

File tree

8 files changed

+73
-64
lines changed

8 files changed

+73
-64
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class ErrorReporter {
117117

118118
void reportDiagnostic(const ClangTidyError &Error) {
119119
const tooling::DiagnosticMessage &Message = Error.Message;
120-
SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
120+
const SourceLocation Loc =
121+
getLocation(Message.FilePath, Message.FileOffset);
121122
// Contains a pair for each attempted fix: location and whether the fix was
122123
// applied successfully.
123124
SmallVector<std::pair<SourceLocation, bool>, 4> FixLocations;
@@ -157,11 +158,11 @@ class ErrorReporter {
157158
// FIXME: Implement better conflict handling.
158159
llvm::errs() << "Trying to resolve conflict: "
159160
<< llvm::toString(std::move(Err)) << "\n";
160-
unsigned NewOffset =
161+
const unsigned NewOffset =
161162
Replacements.getShiftedCodePosition(R.getOffset());
162-
unsigned NewLength = Replacements.getShiftedCodePosition(
163-
R.getOffset() + R.getLength()) -
164-
NewOffset;
163+
const unsigned NewLength = Replacements.getShiftedCodePosition(
164+
R.getOffset() + R.getLength()) -
165+
NewOffset;
165166
if (NewLength == R.getLength()) {
166167
R = Replacement(R.getFilePath(), NewOffset, NewLength,
167168
R.getReplacementText());
@@ -200,7 +201,7 @@ class ErrorReporter {
200201

201202
for (const auto &FileAndReplacements : FileReplacements) {
202203
Rewriter Rewrite(SourceMgr, LangOpts);
203-
StringRef File = FileAndReplacements.first();
204+
const StringRef File = FileAndReplacements.first();
204205
VFS.setCurrentWorkingDirectory(FileAndReplacements.second.BuildDir);
205206
llvm::ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
206207
SourceMgr.getFileManager().getBufferForFile(File);
@@ -210,7 +211,7 @@ class ErrorReporter {
210211
// FIXME: Maybe don't apply fixes for other files as well.
211212
continue;
212213
}
213-
StringRef Code = Buffer.get()->getBuffer();
214+
const StringRef Code = Buffer.get()->getBuffer();
214215
auto Style = format::getStyle(
215216
*Context.getOptionsForFile(File).FormatStyle, File, "none");
216217
if (!Style) {
@@ -262,7 +263,7 @@ class ErrorReporter {
262263
if (!File)
263264
return {};
264265

265-
FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
266+
const FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
266267
return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
267268
}
268269

@@ -284,7 +285,8 @@ class ErrorReporter {
284285
}
285286

286287
void reportNote(const tooling::DiagnosticMessage &Message) {
287-
SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
288+
const SourceLocation Loc =
289+
getLocation(Message.FilePath, Message.FileOffset);
288290
auto Diag =
289291
Diags.Report(Loc, Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
290292
<< Message.Message;
@@ -296,8 +298,9 @@ class ErrorReporter {
296298
CharSourceRange getRange(const FileByteRange &Range) {
297299
SmallString<128> AbsoluteFilePath{Range.FilePath};
298300
Files.makeAbsolutePath(AbsoluteFilePath);
299-
SourceLocation BeginLoc = getLocation(AbsoluteFilePath, Range.FileOffset);
300-
SourceLocation EndLoc = BeginLoc.getLocWithOffset(Range.Length);
301+
const SourceLocation BeginLoc =
302+
getLocation(AbsoluteFilePath, Range.FileOffset);
303+
const SourceLocation EndLoc = BeginLoc.getLocWithOffset(Range.Length);
301304
// Retrieve the source range for applicable highlights and fixes. Macro
302305
// definition on the command line have locations in a virtual buffer and
303306
// don't have valid file paths and are therefore not applicable.
@@ -353,7 +356,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
353356
if (Context.canExperimentalCustomChecks() && custom::RegisterCustomChecks)
354357
custom::RegisterCustomChecks(Context.getOptions(), *CheckFactories);
355358
#endif
356-
for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
359+
for (ClangTidyModuleRegistry::entry const E :
360+
ClangTidyModuleRegistry::entries()) {
357361
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
358362
Module->addCheckFactories(*CheckFactories);
359363
}
@@ -394,8 +398,9 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
394398
// Always add all core checkers if any other static analyzer check is enabled.
395399
// This is currently necessary, as other path sensitive checks rely on the
396400
// core checkers.
397-
for (StringRef CheckName : RegisteredCheckers) {
398-
std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
401+
for (const StringRef CheckName : RegisteredCheckers) {
402+
const std::string ClangTidyCheckName(
403+
(AnalyzerCheckNamePrefix + CheckName).str());
399404

400405
if (CheckName.starts_with("core") ||
401406
Context.isCheckEnabled(ClangTidyCheckName)) {
@@ -504,7 +509,7 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
504509

505510
ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
506511
ClangTidyOptions::OptionMap Options;
507-
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
512+
const std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
508513
CheckFactories->createChecks(&Context);
509514
for (const auto &Check : Checks)
510515
Check->storeOptions(Options);
@@ -564,7 +569,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
564569
std::make_shared<PCHContainerOperations>(), BaseFS);
565570

566571
// Add extra arguments passed by the clang-tidy command-line.
567-
ArgumentsAdjuster PerFileExtraArgumentsInserter =
572+
const ArgumentsAdjuster PerFileExtraArgumentsInserter =
568573
[&Context](const CommandLineArguments &Args, StringRef Filename) {
569574
ClangTidyOptions Opts = Context.getOptionsForFile(Filename);
570575
CommandLineArguments AdjustedArgs = Args;
@@ -703,7 +708,7 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
703708

704709
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
705710
SmallString<64> Buffer(AnalyzerCheckNamePrefix);
706-
size_t DefSize = Buffer.size();
711+
const size_t DefSize = Buffer.size();
707712
for (const auto &AnalyzerCheck : AnalyzerOptions::getRegisteredCheckers(
708713
AllowEnablingAnalyzerAlphaCheckers)) {
709714
Buffer.truncate(DefSize);

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
161161
if (Iter == CheckOptions.end())
162162
return std::nullopt;
163163

164-
StringRef Value = Iter->getValue().Value;
164+
const StringRef Value = Iter->getValue().Value;
165165
StringRef Closest;
166166
unsigned EditDistance = 3;
167167
for (const auto &NameAndEnum : Mapping) {
@@ -173,7 +173,7 @@ ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
173173
EditDistance = 0;
174174
continue;
175175
}
176-
unsigned Distance =
176+
const unsigned Distance =
177177
Value.edit_distance(NameAndEnum.second, true, EditDistance);
178178
if (Distance < EditDistance) {
179179
EditDistance = Distance;

clang-tools-extra/clang-tidy/ClangTidyCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
458458
template <typename T>
459459
std::enable_if_t<std::is_enum_v<T>, std::vector<NameAndValue>>
460460
typeEraseMapping() const {
461-
ArrayRef<std::pair<T, StringRef>> Mapping =
461+
const ArrayRef<std::pair<T, StringRef>> Mapping =
462462
OptionEnumMapping<T>::getEnumMapping();
463463
std::vector<NameAndValue> Result;
464464
Result.reserve(Mapping.size());

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
6161
// FIXME: Remove this once there's a better way to pass check names than
6262
// appending the check name to the message in ClangTidyContext::diag and
6363
// using getCustomDiagID.
64-
std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
64+
const std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
6565
Message.consume_back(CheckNameInMessage);
6666

6767
auto TidyMessage =
@@ -77,7 +77,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
7777
if (SourceRange.isCharRange())
7878
return SourceRange;
7979
assert(SourceRange.isTokenRange());
80-
SourceLocation End = Lexer::getLocForEndOfToken(
80+
const SourceLocation End = Lexer::getLocForEndOfToken(
8181
SourceRange.getEnd(), 0, Loc.getManager(), LangOpts);
8282
return CharSourceRange::getCharRange(SourceRange.getBegin(), End);
8383
};
@@ -114,14 +114,14 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
114114
Level == DiagnosticsEngine::Note ? &Error.Notes.back() : &Error.Message;
115115

116116
for (const auto &FixIt : Hints) {
117-
CharSourceRange Range = FixIt.RemoveRange;
117+
const CharSourceRange Range = FixIt.RemoveRange;
118118
assert(Range.getBegin().isValid() && Range.getEnd().isValid() &&
119119
"Invalid range in the fix-it hint.");
120120
assert(Range.getBegin().isFileID() && Range.getEnd().isFileID() &&
121121
"Only file locations supported in fix-it hints.");
122122

123-
tooling::Replacement Replacement(Loc.getManager(), Range,
124-
FixIt.CodeToInsert);
123+
const tooling::Replacement Replacement(Loc.getManager(), Range,
124+
FixIt.CodeToInsert);
125125
llvm::Error Err =
126126
DiagWithFix->Fix[Replacement.getFilePath()].add(Replacement);
127127
// FIXME: better error handling (at least, don't let other replacements be
@@ -177,7 +177,7 @@ DiagnosticBuilder ClangTidyContext::diag(
177177
StringRef CheckName, SourceLocation Loc, StringRef Description,
178178
DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
179179
assert(Loc.isValid());
180-
unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
180+
const unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
181181
Level, (Description + " [" + CheckName + "]").str());
182182
CheckNamesByDiagnosticID.try_emplace(ID, CheckName);
183183
return DiagEngine->Report(Loc, ID);
@@ -186,7 +186,7 @@ DiagnosticBuilder ClangTidyContext::diag(
186186
DiagnosticBuilder ClangTidyContext::diag(
187187
StringRef CheckName, StringRef Description,
188188
DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
189-
unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
189+
const unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
190190
Level, (Description + " [" + CheckName + "]").str());
191191
CheckNamesByDiagnosticID.try_emplace(ID, CheckName);
192192
return DiagEngine->Report(ID);
@@ -195,10 +195,11 @@ DiagnosticBuilder ClangTidyContext::diag(
195195
DiagnosticBuilder ClangTidyContext::diag(const tooling::Diagnostic &Error) {
196196
SourceManager &SM = DiagEngine->getSourceManager();
197197
FileManager &FM = SM.getFileManager();
198-
FileEntryRef File = llvm::cantFail(FM.getFileRef(Error.Message.FilePath));
199-
FileID ID = SM.getOrCreateFileID(File, SrcMgr::C_User);
200-
SourceLocation FileStartLoc = SM.getLocForStartOfFile(ID);
201-
SourceLocation Loc = FileStartLoc.getLocWithOffset(
198+
const FileEntryRef File =
199+
llvm::cantFail(FM.getFileRef(Error.Message.FilePath));
200+
const FileID ID = SM.getOrCreateFileID(File, SrcMgr::C_User);
201+
const SourceLocation FileStartLoc = SM.getLocForStartOfFile(ID);
202+
const SourceLocation Loc = FileStartLoc.getLocWithOffset(
202203
static_cast<SourceLocation::IntTy>(Error.Message.FileOffset));
203204
return diag(Error.DiagnosticName, Loc, Error.Message.Message,
204205
static_cast<DiagnosticIDs::Level>(Error.DiagLevel));
@@ -214,7 +215,7 @@ bool ClangTidyContext::shouldSuppressDiagnostic(
214215
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
215216
SmallVectorImpl<tooling::Diagnostic> &NoLintErrors, bool AllowIO,
216217
bool EnableNoLintBlocks) {
217-
std::string CheckName = getCheckName(Info.getID());
218+
const std::string CheckName = getCheckName(Info.getID());
218219
return NoLintHandler.shouldSuppress(DiagLevel, Info, CheckName, NoLintErrors,
219220
AllowIO, EnableNoLintBlocks);
220221
}
@@ -226,7 +227,7 @@ void ClangTidyContext::setSourceManager(SourceManager *SourceMgr) {
226227
static bool parseFileExtensions(llvm::ArrayRef<std::string> AllFileExtensions,
227228
FileExtensionsSet &FileExtensions) {
228229
FileExtensions.clear();
229-
for (StringRef Suffix : AllFileExtensions) {
230+
for (const StringRef Suffix : AllFileExtensions) {
230231
StringRef Extension = Suffix.trim();
231232
if (!llvm::all_of(Extension, isAlphanumeric))
232233
return false;
@@ -294,11 +295,11 @@ bool ClangTidyContext::treatAsError(StringRef CheckName) const {
294295
}
295296

296297
std::string ClangTidyContext::getCheckName(unsigned DiagnosticID) const {
297-
std::string ClangWarningOption = std::string(
298+
const std::string ClangWarningOption = std::string(
298299
DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(DiagnosticID));
299300
if (!ClangWarningOption.empty())
300301
return "clang-diagnostic-" + ClangWarningOption;
301-
llvm::DenseMap<unsigned, std::string>::const_iterator I =
302+
const llvm::DenseMap<unsigned, std::string>::const_iterator I =
302303
CheckNamesByDiagnosticID.find(DiagnosticID);
303304
if (I != CheckNamesByDiagnosticID.end())
304305
return I->second;
@@ -316,7 +317,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
316317

317318
void ClangTidyDiagnosticConsumer::finalizeLastError() {
318319
if (!Errors.empty()) {
319-
ClangTidyError &Error = Errors.back();
320+
const ClangTidyError &Error = Errors.back();
320321
if (Error.DiagnosticName == "clang-tidy-config") {
321322
// Never ignore these.
322323
} else if (!Context.isCheckEnabled(Error.DiagnosticName) &&
@@ -436,8 +437,8 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
436437
Level = ClangTidyError::Remark;
437438
}
438439

439-
bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning &&
440-
Context.treatAsError(CheckName);
440+
const bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning &&
441+
Context.treatAsError(CheckName);
441442
Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(),
442443
IsWarningAsError);
443444
}
@@ -491,8 +492,9 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
491492
// Acquire a diagnostic ID also in the external diagnostics engine.
492493
auto DiagLevelAndFormatString =
493494
Context.getDiagLevelAndFormatString(Info.getID(), Info.getLocation());
494-
unsigned ExternalID = ExternalDiagEngine->getDiagnosticIDs()->getCustomDiagID(
495-
DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);
495+
const unsigned ExternalID =
496+
ExternalDiagEngine->getDiagnosticIDs()->getCustomDiagID(
497+
DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);
496498

497499
// Forward the details.
498500
auto Builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
@@ -501,7 +503,7 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
501503
for (auto Range : Info.getRanges())
502504
Builder << Range;
503505
for (unsigned Index = 0; Index < Info.getNumArgs(); ++Index) {
504-
DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);
506+
const DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);
505507
switch (Kind) {
506508
case clang::DiagnosticsEngine::ak_std_string:
507509
Builder << Info.getArgStdStr(Index);
@@ -574,7 +576,7 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
574576
// FIXME: We start with a conservative approach here, but the actual type of
575577
// location needed depends on the check (in particular, where this check wants
576578
// to apply fixes).
577-
FileID FID = Sources.getDecomposedExpansionLoc(Location).first;
579+
const FileID FID = Sources.getDecomposedExpansionLoc(Location).first;
578580
OptionalFileEntryRef File = Sources.getFileEntryRefForID(FID);
579581

580582
// -DMACRO definitions on the command line have locations in a virtual buffer
@@ -585,13 +587,13 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
585587
return;
586588
}
587589

588-
StringRef FileName(File->getName());
590+
const StringRef FileName(File->getName());
589591
LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
590592
Sources.isInMainFile(Location) ||
591593
(getHeaderFilter()->match(FileName) &&
592594
!getExcludeHeaderFilter()->match(FileName));
593595

594-
unsigned LineNumber = Sources.getExpansionLineNumber(Location);
596+
const unsigned LineNumber = Sources.getExpansionLineNumber(Location);
595597
LastErrorPassesLineFilter =
596598
LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);
597599
}
@@ -707,8 +709,8 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
707709
for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
708710
for (const auto &FileAndReplace : *ErrorFixes[I].second) {
709711
for (const auto &Replace : FileAndReplace.second) {
710-
unsigned Begin = Replace.getOffset();
711-
unsigned End = Begin + Replace.getLength();
712+
const unsigned Begin = Replace.getOffset();
713+
const unsigned End = Begin + Replace.getLength();
712714
auto &Events = FileEvents[Replace.getFilePath()];
713715
if (Begin == End) {
714716
Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
@@ -767,7 +769,7 @@ struct LessClangTidyError {
767769
};
768770
struct EqualClangTidyError {
769771
bool operator()(const ClangTidyError &LHS, const ClangTidyError &RHS) const {
770-
LessClangTidyError Less;
772+
const LessClangTidyError Less;
771773
return !Less(LHS, RHS) && !Less(RHS, LHS);
772774
}
773775
};
@@ -803,7 +805,7 @@ void ClangTidyDiagnosticConsumer::removeDuplicatedDiagnosticsOfAliasCheckers() {
803805
auto IT = Errors.begin();
804806
while (IT != Errors.end()) {
805807
ClangTidyError &Error = *IT;
806-
std::pair<UniqueErrorSet::iterator, bool> Inserted =
808+
const std::pair<UniqueErrorSet::iterator, bool> Inserted =
807809
UniqueErrors.insert(&Error);
808810

809811
// Unique error, we keep it and move along.

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
119119
yamlize(IO, NOpts->Options, true, Ctx);
120120
} else if (isa<MappingNode>(I.getCurrentNode())) {
121121
IO.beginMapping();
122-
for (StringRef Key : IO.keys()) {
122+
for (const StringRef Key : IO.keys()) {
123123
// Requires 'llvm::yaml::IO' to accept 'StringRef'
124124
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
125125
IO.mapRequired(Key.data(), Val[Key].Value);
@@ -392,7 +392,7 @@ llvm::ErrorOr<llvm::SmallString<128>>
392392
FileOptionsBaseProvider::getNormalizedAbsolutePath(llvm::StringRef Path) {
393393
assert(FS && "FS must be set.");
394394
llvm::SmallString<128> NormalizedAbsolutePath = {Path};
395-
std::error_code Err = FS->makeAbsolute(NormalizedAbsolutePath);
395+
const std::error_code Err = FS->makeAbsolute(NormalizedAbsolutePath);
396396
if (Err)
397397
return Err;
398398
llvm::sys::path::remove_dots(NormalizedAbsolutePath, /*remove_dot_dot=*/true);
@@ -463,16 +463,16 @@ FileOptionsProvider::getRawOptions(StringRef FileName) {
463463
LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName
464464
<< "...\n");
465465

466-
llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
466+
const llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
467467
getNormalizedAbsolutePath(FileName);
468468
if (!AbsoluteFilePath)
469469
return {};
470470

471471
std::vector<OptionsSource> RawOptions =
472472
DefaultOptionsProvider::getRawOptions(AbsoluteFilePath->str());
473473
addRawFileOptions(AbsoluteFilePath->str(), RawOptions);
474-
OptionsSource CommandLineOptions(OverrideOptions,
475-
OptionsSourceTypeCheckCommandLineOption);
474+
const OptionsSource CommandLineOptions(
475+
OverrideOptions, OptionsSourceTypeCheckCommandLineOption);
476476

477477
RawOptions.push_back(CommandLineOptions);
478478
return RawOptions;
@@ -502,7 +502,7 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef Directory) {
502502

503503
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
504504
FS->getBufferForFile(ConfigFile);
505-
if (std::error_code EC = Text.getError()) {
505+
if (const std::error_code EC = Text.getError()) {
506506
llvm::errs() << "Can't read " << ConfigFile << ": " << EC.message()
507507
<< "\n";
508508
continue;

0 commit comments

Comments
 (0)