[FileSpecList] Add EmplaceBack method (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 18 Jul 2019 20:19:24 +0000 (20:19 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 18 Jul 2019 20:19:24 +0000 (20:19 +0000)
Instead of having to write FileSpecList::Append(FileSpec(args)) you can
now call FileSpecList::EmplaceBack(args), similar to
std::vector<>::emplace_back.

llvm-svn: 366489

lldb/include/lldb/Core/FileSpecList.h
lldb/source/Core/SearchFilter.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

index 79623ef..81fb07d 100644 (file)
@@ -76,6 +76,15 @@ public:
   ///     \b true if the file was appended, \b false otherwise.
   bool AppendIfUnique(const FileSpec &file);
 
+  /// Inserts a new FileSpec into the FileSpecList constructed in-place with
+  /// the given arguments.
+  ///
+  /// \param[in] args
+  ///     Arguments to create the FileSpec
+  template <class... Args> void EmplaceBack(Args &&... args) {
+    m_files.emplace_back(std::forward<Args>(args)...);
+  }
+
   /// Clears the file list.
   void Clear();
 
index 531fa07..c9a6766 100644 (file)
@@ -640,7 +640,7 @@ SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
             "SFBM::CFSD: filter module item %zu not a string.", i);
         return nullptr;
       }
-      modules.Append(FileSpec(module));
+      modules.EmplaceBack(module);
     }
   }
 
@@ -703,7 +703,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
             "SFBM::CFSD: filter module item %zu not a string.", i);
         return result_sp;
       }
-      modules.Append(FileSpec(module));
+      modules.EmplaceBack(module);
     }
   }
 
@@ -725,7 +725,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
           "SFBM::CFSD: filter cu item %zu not a string.", i);
       return nullptr;
     }
-    cus.Append(FileSpec(cu));
+    cus.EmplaceBack(cu);
   }
 
   return std::make_shared<SearchFilterByModuleListAndCU>(
index 41f38a4..52519c8 100644 (file)
@@ -471,8 +471,8 @@ lldb::SearchFilterSP ItaniumABILanguageRuntime::CreateExceptionSearchFilter() {
   if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
     // Limit the number of modules that are searched for these breakpoints for
     // Apple binaries.
-    filter_modules.Append(FileSpec("libc++abi.dylib"));
-    filter_modules.Append(FileSpec("libSystem.B.dylib"));
+    filter_modules.EmplaceBack("libc++abi.dylib");
+    filter_modules.EmplaceBack("libSystem.B.dylib");
   }
   return target.GetSearchFilterForModuleList(&filter_modules);
 }
index fab3790..cc2b3ae 100644 (file)
@@ -946,10 +946,10 @@ uint32_t ObjectFilePECOFF::ParseDependentModules() {
     dll_specs.GetDirectory().SetString(m_file.GetDirectory().GetCString());
 
     if (!llvm::sys::fs::real_path(dll_specs.GetPath(), dll_fullpath))
-      m_deps_filespec->Append(FileSpec(dll_fullpath));
+      m_deps_filespec->EmplaceBack(dll_fullpath);
     else {
       // Known DLLs or DLL not found in the object file directory.
-      m_deps_filespec->Append(FileSpec(dll_name));
+      m_deps_filespec->EmplaceBack(dll_name);
     }
   }
   return m_deps_filespec->GetSize();
index 9559871..c1292b2 100644 (file)
@@ -1227,7 +1227,7 @@ BreakpointSP PlatformDarwin::SetThreadCreationBreakpoint(Target &target) {
   FileSpecList bp_modules;
   for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++) {
     const char *bp_module = g_bp_modules[i];
-    bp_modules.Append(FileSpec(bp_module));
+    bp_modules.EmplaceBack(bp_module);
   }
 
   bool internal = true;
index e2ddcfc..fb5a94f 100644 (file)
@@ -833,7 +833,7 @@ SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
   auto iter_bool = m_type_unit_support_files.try_emplace(offset);
   FileSpecList &list = iter_bool.first->second;
   if (iter_bool.second) {
-    list.Append(FileSpec());
+    list.EmplaceBack();
     DWARFDebugLine::ParseSupportFiles(GetObjectFile()->GetModule(),
                                       m_context.getOrLoadLineData(), offset,
                                       list, &tu);