diff options
Diffstat (limited to 'clang/lib/Tooling/Execution.cpp')
-rw-r--r-- | clang/lib/Tooling/Execution.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Tooling/Execution.cpp b/clang/lib/Tooling/Execution.cpp index ff68f85adb2..5d6559fb2b4 100644 --- a/clang/lib/Tooling/Execution.cpp +++ b/clang/lib/Tooling/Execution.cpp @@ -21,10 +21,19 @@ static llvm::cl::opt<std::string> llvm::cl::init("standalone")); void InMemoryToolResults::addResult(StringRef Key, StringRef Value) { - KVResults.push_back({Key.str(), Value.str()}); + auto Intern = [&](StringRef &V) { + auto R = Strings.insert(V); + if (R.second) { // A new entry, create a new string copy. + *R.first = StringsPool.save(V); + } + V = *R.first; + }; + Intern(Key); + Intern(Value); + KVResults.push_back({Key, Value}); } -std::vector<std::pair<std::string, std::string>> +std::vector<std::pair<llvm::StringRef, llvm::StringRef>> InMemoryToolResults::AllKVResults() { return KVResults; } |