[PATCH] D44643: [Lex] Change HeaderSearchOptions arguments to std::string.

Frederich Munch via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 19 12:38:35 PDT 2018


marsupial created this revision.
marsupial added reviewers: eugene, boris.
marsupial added a project: clang.
marsupial updated this revision to Diff 138982.

Arguments passed to HeaderSearchOptions methods are stored as std::strings, having them converted to a StringRef at the call site can result in unnecessary conversions and copies.


https://reviews.llvm.org/D44643

Files:
  include/clang/Lex/HeaderSearchOptions.h


Index: include/clang/Lex/HeaderSearchOptions.h
===================================================================
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-      : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-        ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-        UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-        UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+      : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+        DisableModuleHash(false), ImplicitModuleMaps(false),
+        ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+        UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+        UseLibcxx(false), Verbose(false),
         ModulesValidateOncePerBuildSession(false),
         ModulesValidateSystemHeaders(false), UseDebugInfo(false),
         ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
                bool IsFramework, bool IgnoreSysRoot) {
-    UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+    UserEntries.emplace_back(std::move(Path), Group, IsFramework, IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-    SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+    SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-    VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+    VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-    PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+    PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44643.138982.patch
Type: text/x-patch
Size: 2423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180319/b5796095/attachment-0001.bin>


More information about the cfe-commits mailing list