diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -345,7 +345,7 @@ if (!OptName.consume_front(AnalyzerPrefix)) continue; // Analyzer options are always local options so we can ignore priority. - AnalyzerOptions.Config[OptName] = Opt.getValue().Value; + AnalyzerOptions.Config[OptName.str()] = Opt.getValue().Value; } } diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -148,7 +148,7 @@ /// make sense for things that do not affect the actual analysis. class AnalyzerOptions : public RefCountedBase { public: - using ConfigTable = llvm::StringMap; + using ConfigTable = std::map; /// Retrieves the list of checkers generated from Checkers.td. This doesn't /// contain statically linked but non-generated checkers and plugin checkers! diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -880,11 +880,11 @@ for (const auto &C : Opts.Config) { // Don't generate anything that came from parseAnalyzerConfigs. It would be // redundant and may not be valid on the command line. - auto Entry = ConfigOpts.Config.find(C.getKey()); - if (Entry != ConfigOpts.Config.end() && Entry->getValue() == C.getValue()) + auto Entry = ConfigOpts.Config.find(C.first); + if (Entry != ConfigOpts.Config.end() && Entry->second == C.second) continue; - GenerateArg(Args, OPT_analyzer_config, C.getKey() + "=" + C.getValue(), SA); + GenerateArg(Args, OPT_analyzer_config, C.first + "=" + C.second, SA); } // Nothing to generate for FullCompilerInvocation. @@ -1019,7 +1019,7 @@ } A->claim(); - Opts.Config[key] = std::string(val); + Opts.Config[key.str()] = val.str(); // FIXME: Remove this hunk after clang-17 released. constexpr auto SingleFAM = @@ -1050,7 +1050,7 @@ static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config, StringRef OptionName, StringRef DefaultVal) { - return Config.insert({OptionName, std::string(DefaultVal)}).first->second; + return Config.insert({OptionName.str(), DefaultVal.str()}).first->second; } static void initOption(AnalyzerOptions::ConfigTable &Config, diff --git a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp --- a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp @@ -259,9 +259,9 @@ class ConfigDumper : public Checker< check::EndOfTranslationUnit > { typedef AnalyzerOptions::ConfigTable Table; - static int compareEntry(const Table::MapEntryTy *const *LHS, - const Table::MapEntryTy *const *RHS) { - return (*LHS)->getKey().compare((*RHS)->getKey()); + static int compareEntry(const Table::value_type *const *LHS, + const Table::value_type *const *RHS) { + return (*LHS)->first.compare((*RHS)->first); } public: @@ -270,7 +270,7 @@ BugReporter &BR) const { const Table &Config = mgr.options.Config; - SmallVector Keys; + SmallVector Keys; for (Table::const_iterator I = Config.begin(), E = Config.end(); I != E; ++I) Keys.push_back(&*I); @@ -278,7 +278,7 @@ llvm::errs() << "[config]\n"; for (unsigned I = 0, E = Keys.size(); I != E; ++I) - llvm::errs() << Keys[I]->getKey() << " = " + llvm::errs() << Keys[I]->first << " = " << (Keys[I]->second.empty() ? "\"\"" : Keys[I]->second) << '\n'; } diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -136,7 +136,7 @@ ConfigTable::const_iterator I = Config.find((Twine(CheckerName) + ":" + OptionName).str()); if (I != E) - return StringRef(I->getValue()); + return StringRef(I->second); size_t Pos = CheckerName.rfind('.'); if (Pos == StringRef::npos) break; diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -357,7 +357,7 @@ // to it's default value, and if we're in non-compatibility mode, we'll also // emit an error. - StringRef SuppliedValue = It.first->getValue(); + StringRef SuppliedValue = It.first->second; if (Option.OptionType == "bool") { if (SuppliedValue != "true" && SuppliedValue != "false") { @@ -366,7 +366,7 @@ << FullOption << "a boolean value"; } - It.first->setValue(std::string(Option.DefaultValStr)); + It.first->second = Option.DefaultValStr.str(); } return; } @@ -380,7 +380,7 @@ << FullOption << "an integer value"; } - It.first->setValue(std::string(Option.DefaultValStr)); + It.first->second = Option.DefaultValStr.str(); } return; } @@ -492,7 +492,7 @@ StringRef SuppliedCheckerOrPackage; StringRef SuppliedOption; std::tie(SuppliedCheckerOrPackage, SuppliedOption) = - Config.getKey().split(':'); + StringRef(Config.first).split(':'); if (SuppliedOption.empty()) continue;