[clang] f13d3f7 - [Tooling] Simplify code with StringMap::operator[] (NFC) (#113071)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 20 09:05:58 PDT 2024


Author: Kazu Hirata
Date: 2024-10-20T09:05:55-07:00
New Revision: f13d3f72118b83e326169592e8f3c5962fd0eb29

URL: https://github.com/llvm/llvm-project/commit/f13d3f72118b83e326169592e8f3c5962fd0eb29
DIFF: https://github.com/llvm/llvm-project/commit/f13d3f72118b83e326169592e8f3c5962fd0eb29.diff

LOG: [Tooling] Simplify code with StringMap::operator[] (NFC) (#113071)

Added: 
    

Modified: 
    clang/lib/Tooling/Inclusions/HeaderIncludes.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 0cb96097415ea8..01b3be700b9fad 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -335,10 +335,9 @@ HeaderIncludes::HeaderIncludes(StringRef FileName, StringRef Code,
 // \p Offset: the start of the line following this include directive.
 void HeaderIncludes::addExistingInclude(Include IncludeToAdd,
                                         unsigned NextLineOffset) {
-  auto Iter =
-      ExistingIncludes.try_emplace(trimInclude(IncludeToAdd.Name)).first;
-  Iter->second.push_back(std::move(IncludeToAdd));
-  auto &CurInclude = Iter->second.back();
+  auto &Incs = ExistingIncludes[trimInclude(IncludeToAdd.Name)];
+  Incs.push_back(std::move(IncludeToAdd));
+  auto &CurInclude = Incs.back();
   // The header name with quotes or angle brackets.
   // Only record the offset of current #include if we can insert after it.
   if (CurInclude.R.getOffset() <= MaxInsertOffset) {


        


More information about the cfe-commits mailing list