Pass ConstString by value (NFC)

My apologies for the large patch. With the exception of ConstString.h
itself it was entirely produced by sed.

ConstString has exactly one const char * data member, so passing a
ConstString by reference is not any more efficient than copying it by
value. In both cases a single pointer is passed. But passing it by
value makes it harder to accidentally return the address of a local
object.

(This fixes rdar://problem/48640859 for the Apple folks)

Differential Revision: https://reviews.llvm.org/D59030

llvm-svn: 355553
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 316f062..1c8e3c7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1836,7 +1836,7 @@
 }
 
 void ClangASTSource::CompleteNamespaceMap(
-    ClangASTImporter::NamespaceMapSP &namespace_map, const ConstString &name,
+    ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
     ClangASTImporter::NamespaceMapSP &parent_map) const {
   static unsigned int invocation_id = 0;
   unsigned int current_id = invocation_id++;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index cf305b4..063d82e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -198,7 +198,7 @@
   ///     one.
   //------------------------------------------------------------------
   void CompleteNamespaceMap(
-      ClangASTImporter::NamespaceMapSP &namespace_map, const ConstString &name,
+      ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
       ClangASTImporter::NamespaceMapSP &parent_map) const override;
 
   //
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 24ca970..5212712 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -309,7 +309,7 @@
 }
 
 bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
-                                                   const ConstString &name,
+                                                   ConstString name,
                                                    TypeFromParser parser_type,
                                                    bool is_result,
                                                    bool is_lvalue) {
@@ -424,7 +424,7 @@
 }
 
 bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
-                                              const ConstString &name,
+                                              ConstString name,
                                               llvm::Value *value, size_t size,
                                               lldb::offset_t alignment) {
   assert(m_struct_vars.get());
@@ -604,7 +604,7 @@
 
 addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
                                                 Process *process,
-                                                const ConstString &name,
+                                                ConstString name,
                                                 lldb::SymbolType symbol_type,
                                                 lldb_private::Module *module) {
   SymbolContextList sc_list;
@@ -702,7 +702,7 @@
   return symbol_load_addr;
 }
 
-addr_t ClangExpressionDeclMap::GetSymbolAddress(const ConstString &name,
+addr_t ClangExpressionDeclMap::GetSymbolAddress(ConstString name,
                                                 lldb::SymbolType symbol_type) {
   assert(m_parser_vars.get());
 
@@ -715,7 +715,7 @@
 }
 
 lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
-    Target &target, ModuleSP &module, const ConstString &name,
+    Target &target, ModuleSP &module, ConstString name,
     CompilerDeclContext *namespace_decl, TypeFromUser *type) {
   VariableList vars;
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index ac6690d..dd866c3 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -138,7 +138,7 @@
   ///     True on success; false otherwise.
   //------------------------------------------------------------------
   bool AddPersistentVariable(const clang::NamedDecl *decl,
-                             const ConstString &name, TypeFromParser type,
+                             ConstString name, TypeFromParser type,
                              bool is_result, bool is_lvalue);
 
   //------------------------------------------------------------------
@@ -163,7 +163,7 @@
   /// @return
   ///     True on success; false otherwise.
   //------------------------------------------------------------------
-  bool AddValueToStruct(const clang::NamedDecl *decl, const ConstString &name,
+  bool AddValueToStruct(const clang::NamedDecl *decl, ConstString name,
                         llvm::Value *value, size_t size,
                         lldb::offset_t alignment);
 
@@ -268,11 +268,11 @@
   ///     Valid load address for the symbol
   //------------------------------------------------------------------
   lldb::addr_t GetSymbolAddress(Target &target, Process *process,
-                                const ConstString &name,
+                                ConstString name,
                                 lldb::SymbolType symbol_type,
                                 Module *module = NULL);
 
-  lldb::addr_t GetSymbolAddress(const ConstString &name,
+  lldb::addr_t GetSymbolAddress(ConstString name,
                                 lldb::SymbolType symbol_type);
 
   //------------------------------------------------------------------
@@ -467,7 +467,7 @@
   ///     The LLDB Variable found, or NULL if none was found.
   //------------------------------------------------------------------
   lldb::VariableSP FindGlobalVariable(Target &target, lldb::ModuleSP &module,
-                                      const ConstString &name,
+                                      ConstString name,
                                       CompilerDeclContext *namespace_decl,
                                       TypeFromUser *type = NULL);
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
index b510cd8..b5a2c80 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -31,7 +31,7 @@
 }
 
 ClangExpressionVariable::ClangExpressionVariable(
-    ExecutionContextScope *exe_scope, Value &value, const ConstString &name,
+    ExecutionContextScope *exe_scope, Value &value, ConstString name,
     uint16_t flags)
     : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
       m_jit_vars() {
@@ -48,7 +48,7 @@
 }
 
 ClangExpressionVariable::ClangExpressionVariable(
-    ExecutionContextScope *exe_scope, const ConstString &name,
+    ExecutionContextScope *exe_scope, ConstString name,
     const TypeFromUser &user_type, lldb::ByteOrder byte_order,
     uint32_t addr_byte_size)
     : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 731ab14..b9767e22 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -62,12 +62,12 @@
                           lldb::ByteOrder byte_order, uint32_t addr_byte_size);
 
   ClangExpressionVariable(ExecutionContextScope *exe_scope, Value &value,
-                          const ConstString &name, uint16_t flags = EVNone);
+                          ConstString name, uint16_t flags = EVNone);
 
   ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp);
 
   ClangExpressionVariable(ExecutionContextScope *exe_scope,
-                          const ConstString &name,
+                          ConstString name,
                           const TypeFromUser &user_type,
                           lldb::ByteOrder byte_order, uint32_t addr_byte_size);
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 9d5ead4..f7eaa8f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -78,7 +78,7 @@
   bool AddModulesForCompileUnit(CompileUnit &cu, ModuleVector &exported_modules,
                                 Stream &error_stream) override;
 
-  uint32_t FindDecls(const ConstString &name, bool append, uint32_t max_matches,
+  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
                      std::vector<clang::NamedDecl *> &decls) override;
 
   void ForEachMacro(const ModuleVector &modules,
@@ -340,7 +340,7 @@
 // ClangImporter::lookupValue
 
 uint32_t
-ClangModulesDeclVendorImpl::FindDecls(const ConstString &name, bool append,
+ClangModulesDeclVendorImpl::FindDecls(ConstString name, bool append,
                                       uint32_t max_matches,
                                       std::vector<clang::NamedDecl *> &decls) {
   if (!m_enabled) {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index d66b443..e77ba86 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -31,7 +31,7 @@
 }
 
 ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable(
-    ExecutionContextScope *exe_scope, const ConstString &name,
+    ExecutionContextScope *exe_scope, ConstString name,
     const CompilerType &compiler_type, lldb::ByteOrder byte_order,
     uint32_t addr_byte_size) {
   return AddNewlyConstructedVariable(new ClangExpressionVariable(
@@ -52,7 +52,7 @@
     m_next_persistent_variable_id--;
 }
 
-void ClangPersistentVariables::RegisterPersistentDecl(const ConstString &name,
+void ClangPersistentVariables::RegisterPersistentDecl(ConstString name,
                                                       clang::NamedDecl *decl) {
   m_persistent_decls.insert(
       std::pair<const char *, clang::NamedDecl *>(name.GetCString(), decl));
@@ -67,7 +67,7 @@
 }
 
 clang::NamedDecl *
-ClangPersistentVariables::GetPersistentDecl(const ConstString &name) {
+ClangPersistentVariables::GetPersistentDecl(ConstString name) {
   PersistentDeclMap::const_iterator i =
       m_persistent_decls.find(name.GetCString());
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index f713dc4..2b5e6de 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -44,7 +44,7 @@
   CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override;
 
   lldb::ExpressionVariableSP CreatePersistentVariable(
-      ExecutionContextScope *exe_scope, const ConstString &name,
+      ExecutionContextScope *exe_scope, ConstString name,
       const CompilerType &compiler_type, lldb::ByteOrder byte_order,
       uint32_t addr_byte_size) override;
 
@@ -54,9 +54,9 @@
     return "$";
   }
 
-  void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl);
+  void RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl);
 
-  clang::NamedDecl *GetPersistentDecl(const ConstString &name);
+  clang::NamedDecl *GetPersistentDecl(ConstString name);
 
   void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) {
     m_hand_loaded_clang_modules.push_back(module);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index 526d787..137a14e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -239,7 +239,7 @@
   ///     The Clang type of the result variable.
   //------------------------------------------------------------------
   void MaybeSetConstantResult(llvm::Constant *initializer,
-                              const lldb_private::ConstString &name,
+                              lldb_private::ConstString name,
                               lldb_private::TypeFromParser type);
 
   //------------------------------------------------------------------