diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-06 10:58:06 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-06 10:58:06 +0000 |
commit | 2928c83b010f7cfdb0f819199d806f6942a7d995 (patch) | |
tree | 0c5a62b287e4c2c693330584a8f1d6024defde66 /include/llvm | |
parent | c128b3e74eaba34a8f6d2b8c3dc19861b9cbd901 (diff) | |
download | llvm-2928c83b010f7cfdb0f819199d806f6942a7d995.tar.gz llvm-2928c83b010f7cfdb0f819199d806f6942a7d995.tar.bz2 llvm-2928c83b010f7cfdb0f819199d806f6942a7d995.tar.xz |
Pass StringRef by value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
25 files changed, 117 insertions, 116 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 73fd635ee2..86e8546adc 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -96,12 +96,12 @@ protected: /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. - unsigned LookupBucketFor(const StringRef &Key); + unsigned LookupBucketFor(StringRef Key); /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. - int FindKey(const StringRef &Key) const; + int FindKey(StringRef Key) const; /// RemoveKey - Remove the specified StringMapEntry from the table, but do not /// delete it. This aborts if the value isn't in the table. @@ -109,7 +109,7 @@ protected: /// RemoveKey - Remove the StringMapEntry for the specified key from the /// table, returning it. If the key is not in the table, this returns null. - StringMapEntryBase *RemoveKey(const StringRef &Key); + StringMapEntryBase *RemoveKey(StringRef Key); private: void init(unsigned Size); public: @@ -282,13 +282,13 @@ public: return const_iterator(TheTable+NumBuckets, true); } - iterator find(const StringRef &Key) { + iterator find(StringRef Key) { int Bucket = FindKey(Key); if (Bucket == -1) return end(); return iterator(TheTable+Bucket); } - const_iterator find(const StringRef &Key) const { + const_iterator find(StringRef Key) const { int Bucket = FindKey(Key); if (Bucket == -1) return end(); return const_iterator(TheTable+Bucket); @@ -296,18 +296,18 @@ public: /// lookup - Return the entry for the specified key, or a default /// constructed value if no such entry exists. - ValueTy lookup(const StringRef &Key) const { + ValueTy lookup(StringRef Key) const { const_iterator it = find(Key); if (it != end()) return it->second; return ValueTy(); } - ValueTy& operator[](const StringRef &Key) { + ValueTy& operator[](StringRef Key) { return GetOrCreateValue(Key).getValue(); } - size_type count(const StringRef &Key) const { + size_type count(StringRef Key) const { return find(Key) == end() ? 0 : 1; } @@ -350,7 +350,7 @@ public: /// exists, return it. Otherwise, default construct a value, insert it, and /// return. template <typename InitTy> - StringMapEntry<ValueTy> &GetOrCreateValue(const StringRef &Key, + StringMapEntry<ValueTy> &GetOrCreateValue(StringRef Key, InitTy Val) { unsigned BucketNo = LookupBucketFor(Key); ItemBucket &Bucket = TheTable[BucketNo]; @@ -373,7 +373,7 @@ public: return *NewItem; } - StringMapEntry<ValueTy> &GetOrCreateValue(const StringRef &Key) { + StringMapEntry<ValueTy> &GetOrCreateValue(StringRef Key) { return GetOrCreateValue(Key, ValueTy()); } @@ -401,7 +401,7 @@ public: V.Destroy(Allocator); } - bool erase(const StringRef &Key) { + bool erase(StringRef Key) { iterator I = find(Key); if (I == end()) return false; erase(I); diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 2fa5c66aae..4e81b84252 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -92,14 +92,14 @@ namespace llvm { /// equals - Check for string equality, this is more efficient than /// compare() when the relative ordering of inequal strings isn't needed. - bool equals(const StringRef &RHS) const { + bool equals(StringRef RHS) const { return (Length == RHS.Length && memcmp(Data, RHS.Data, RHS.Length) == 0); } /// compare - Compare two strings; the result is -1, 0, or 1 if this string /// is lexicographically less than, equal to, or greater than the \arg RHS. - int compare(const StringRef &RHS) const { + int compare(StringRef RHS) const { // Check the prefix for a mismatch. if (int Res = memcmp(Data, RHS.Data, std::min(Length, RHS.Length))) return Res < 0 ? -1 : 1; @@ -135,12 +135,12 @@ namespace llvm { /// @{ /// startswith - Check if this string starts with the given \arg Prefix. - bool startswith(const StringRef &Prefix) const { + bool startswith(StringRef Prefix) const { return substr(0, Prefix.Length).equals(Prefix); } /// endswith - Check if this string ends with the given \arg Suffix. - bool endswith(const StringRef &Suffix) const { + bool endswith(StringRef Suffix) const { return slice(size() - Suffix.Length, size()).equals(Suffix); } @@ -163,7 +163,7 @@ namespace llvm { /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. - size_t find(const StringRef &Str) const; + size_t find(StringRef Str) const; /// rfind - Search for the last character \arg C in the string. /// @@ -184,7 +184,7 @@ namespace llvm { /// /// \return - The index of the last occurence of \arg Str, or npos if not /// found. - size_t rfind(const StringRef &Str) const; + size_t rfind(StringRef Str) const; /// find_first_of - Find the first instance of the specified character or /// return npos if not in string. Same as find. @@ -213,7 +213,7 @@ namespace llvm { /// count - Return the number of non-overlapped occurrences of \arg Str in /// the string. - size_t count(const StringRef &Str) const; + size_t count(StringRef Str) const; /// getAsInteger - Parse the current string as an integer of the specified /// radix. If Radix is specified as zero, this does radix autosensing using @@ -304,27 +304,27 @@ namespace llvm { /// @name StringRef Comparison Operators /// @{ - inline bool operator==(const StringRef &LHS, const StringRef &RHS) { + inline bool operator==(StringRef LHS, StringRef RHS) { return LHS.equals(RHS); } - inline bool operator!=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); } - inline bool operator<(const StringRef &LHS, const StringRef &RHS) { + inline bool operator<(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) == -1; } - inline bool operator<=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator<=(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) != 1; } - inline bool operator>(const StringRef &LHS, const StringRef &RHS) { + inline bool operator>(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) == 1; } - inline bool operator>=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator>=(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) != -1; } diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 7fb0014dc8..1b2a323b4e 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -218,23 +218,23 @@ public: /// setArchName - Set the architecture (first) component of the /// triple by name. - void setArchName(const StringRef &Str); + void setArchName(StringRef Str); /// setVendorName - Set the vendor (second) component of the triple /// by name. - void setVendorName(const StringRef &Str); + void setVendorName(StringRef Str); /// setOSName - Set the operating system (third) component of the /// triple by name. - void setOSName(const StringRef &Str); + void setOSName(StringRef Str); /// setEnvironmentName - Set the optional environment (fourth) /// component of the triple by name. - void setEnvironmentName(const StringRef &Str); + void setEnvironmentName(StringRef Str); /// setOSAndEnvironmentName - Set the operating system and optional /// environment components with a single string. - void setOSAndEnvironmentName(const StringRef &Str); + void setOSAndEnvironmentName(StringRef Str); /// @} /// @name Static helpers for IDs. @@ -265,12 +265,12 @@ public: /// getArchTypeForLLVMName - The canonical type for the given LLVM /// architecture name (e.g., "x86"). - static ArchType getArchTypeForLLVMName(const StringRef &Str); + static ArchType getArchTypeForLLVMName(StringRef Str); /// getArchTypeForDarwinArchName - Get the architecture type for a "Darwin" /// architecture name, for example as accepted by "gcc -arch" (see also /// arch(3)). - static ArchType getArchTypeForDarwinArchName(const StringRef &Str); + static ArchType getArchTypeForDarwinArchName(StringRef Str); /// @} }; diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h index e48a190833..2b1b85ea41 100644 --- a/include/llvm/Bitcode/BitstreamWriter.h +++ b/include/llvm/Bitcode/BitstreamWriter.h @@ -294,7 +294,7 @@ private: /// known to exist at the end of the the record. template<typename uintty> void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, - const StringRef &Blob) { + StringRef Blob) { const char *BlobData = Blob.data(); unsigned BlobLen = (unsigned) Blob.size(); unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; @@ -422,7 +422,7 @@ public: /// of the record. template<typename uintty> void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, - const StringRef &Blob) { + StringRef Blob) { EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob); } template<typename uintty> @@ -435,7 +435,7 @@ public: /// that end with an array. template<typename uintty> void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, - const StringRef &Array) { + StringRef Array) { EmitRecordWithAbbrevImpl(Abbrev, Vals, Array); } template<typename uintty> diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 99928d9b85..caa13f6ac6 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -86,7 +86,7 @@ public: /// Return a ConstantInt constructed from the string strStart with the given /// radix. - static ConstantInt *get(const IntegerType *Ty, const StringRef &Str, + static ConstantInt *get(const IntegerType *Ty, StringRef Str, uint8_t radix); /// If Ty is a vector type, return a Constant with a splat of the given @@ -255,7 +255,7 @@ public: /// only be used for simple constant values like 2.0/1.0 etc, that are /// known-valid both as host double and as the target format. static Constant *get(const Type* Ty, double V); - static Constant *get(const Type* Ty, const StringRef &Str); + static Constant *get(const Type* Ty, StringRef Str); static ConstantFP *get(LLVMContext &Context, const APFloat &V); static ConstantFP *getNegativeZero(const Type* Ty); static ConstantFP *getInfinity(const Type *Ty, bool Negative = false); @@ -353,7 +353,7 @@ public: /// of the array by one (you've been warned). However, in some situations /// this is not desired so if AddNull==false then the string is copied without /// null termination. - static Constant *get(LLVMContext &Context, const StringRef &Initializer, + static Constant *get(LLVMContext &Context, StringRef Initializer, bool AddNull = true); /// Transparently provide more efficient getOperand methods. diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index 7b0de34d9c..b8d219c726 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -90,7 +90,7 @@ public: bool hasSection() const { return !Section.empty(); } const std::string &getSection() const { return Section; } - void setSection(const StringRef &S) { Section = S; } + void setSection(StringRef S) { Section = S; } /// If the usage is empty (except transitively dead constants), then this /// global value can can be safely deleted since the destructor will diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index d54870e49f..482e53e3fe 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -33,16 +33,16 @@ class InlineAsm : public Value { bool HasSideEffects; bool IsAlignStack; - InlineAsm(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects, + InlineAsm(const FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, bool isAlignStack = false); virtual ~InlineAsm(); public: /// InlineAsm::get - Return the the specified uniqued inline asm string. /// - static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects, + static InlineAsm *get(const FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, bool isAlignStack = false); bool hasSideEffects() const { return HasSideEffects; } @@ -65,7 +65,7 @@ public: /// the specified constraint string is legal for the type. This returns true /// if legal, false if not. /// - static bool Verify(const FunctionType *Ty, const StringRef &Constraints); + static bool Verify(const FunctionType *Ty, StringRef Constraints); // Constraint String Parsing enum ConstraintPrefix { @@ -110,7 +110,7 @@ public: /// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the /// fields in this structure. If the constraint string is not understood, /// return true, otherwise return false. - bool Parse(const StringRef &Str, + bool Parse(StringRef Str, std::vector<InlineAsm::ConstraintInfo> &ConstraintsSoFar); }; @@ -118,7 +118,7 @@ public: /// constraints and their prefixes. If this returns an empty vector, and if /// the constraint string itself isn't empty, there was an error parsing. static std::vector<ConstraintInfo> - ParseConstraints(const StringRef &ConstraintString); + ParseConstraints(StringRef ConstraintString); /// ParseConstraints - Parse the constraints of this inlineasm object, /// returning them the same way that ParseConstraints(str) does. diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 1e1da86711..a68a2e0fd3 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -65,8 +65,8 @@ class Linker { /// Construct the Linker with an empty module which will be given the /// name \p progname. \p progname will also be used for error messages. /// @brief Construct with empty module - Linker(const StringRef &progname, ///< name of tool running linker - const StringRef &modulename, ///< name of linker's end-result module + Linker(StringRef progname, ///< name of tool running linker + StringRef modulename, ///< name of linker's end-result module LLVMContext &C, ///< Context for global info unsigned Flags = 0 ///< ControlFlags (one or more |'d together) ); @@ -74,7 +74,7 @@ class Linker { /// Construct the Linker with a previously defined module, \p aModule. Use /// \p progname for the name of the program in error messages. /// @brief Construct with existing module - Linker(const StringRef& progname, Module* aModule, unsigned Flags = 0); + Linker(StringRef progname, Module* aModule, unsigned Flags = 0); /// Destruct the Linker. /// @brief Destructor @@ -214,8 +214,8 @@ class Linker { /// @returns true if an error occurs, false otherwise /// @brief Link one library into the module bool LinkInLibrary ( - const StringRef &Library, ///< The library to link in - bool& is_native ///< Indicates if lib a native library + StringRef Library, ///< The library to link in + bool& is_native ///< Indicates if lib a native library ); /// This function links one bitcode archive, \p Filename, into the module. @@ -267,7 +267,7 @@ class Linker { /// will be empty (i.e. sys::Path::isEmpty() will return true). /// @returns A sys::Path to the found library /// @brief Find a library from its short name. - sys::Path FindLib(const StringRef &Filename); + sys::Path FindLib(StringRef Filename); /// @} /// @name Implementation @@ -277,9 +277,9 @@ class Linker { /// Module it contains (wrapped in an auto_ptr), or 0 if an error occurs. std::auto_ptr<Module> LoadObject(const sys::Path& FN); - bool warning(const StringRef &message); - bool error(const StringRef &message); - void verbose(const StringRef &message); + bool warning(StringRef message); + bool error(StringRef message); + void verbose(StringRef message); /// @} /// @name Data diff --git a/include/llvm/MC/MCAsmLexer.h b/include/llvm/MC/MCAsmLexer.h index e369e30a9a..da471d284c 100644 --- a/include/llvm/MC/MCAsmLexer.h +++ b/include/llvm/MC/MCAsmLexer.h @@ -56,7 +56,7 @@ struct AsmToken { public: AsmToken() {} - AsmToken(TokenKind _Kind, const StringRef &_Str, int64_t _IntVal = 0) + AsmToken(TokenKind _Kind, StringRef _Str, int64_t _IntVal = 0) : Kind(_Kind), Str(_Str), IntVal(_IntVal) {} TokenKind getKind() const { return Kind; } diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index fa20f45064..95c6bd4bb4 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -49,7 +49,7 @@ namespace llvm { /// CreateSymbol - Create a new symbol with the specified @param Name. /// /// @param Name - The symbol name, which must be unique across all symbols. - MCSymbol *CreateSymbol(const StringRef &Name); + MCSymbol *CreateSymbol(StringRef Name); /// GetOrCreateSymbol - Lookup the symbol inside with the specified /// @param Name. If it exists, return it. If not, create a forward @@ -58,7 +58,7 @@ namespace llvm { /// @param Name - The symbol name, which must be unique across all symbols. /// @param IsTemporary - Whether this symbol is an assembler temporary, /// which should not survive into the symbol table for the translation unit. - MCSymbol *GetOrCreateSymbol(const StringRef &Name); + MCSymbol *GetOrCreateSymbol(StringRef Name); MCSymbol *GetOrCreateSymbol(const Twine &Name); /// CreateTemporarySymbol - Create a new temporary symbol with the specified @@ -67,10 +67,10 @@ namespace llvm { /// @param Name - The symbol name, for debugging purposes only, temporary /// symbols do not surive assembly. If non-empty the name must be unique /// across all symbols. - MCSymbol *CreateTemporarySymbol(const StringRef &Name = ""); + MCSymbol *CreateTemporarySymbol(StringRef Name = ""); /// LookupSymbol - Get the symbol for @param Name, or null. - MCSymbol *LookupSymbol(const StringRef &Name) const; + MCSymbol *LookupSymbol(StringRef Name) const; /// @} diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index 4318628e5f..13d40eca7c 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -120,7 +120,7 @@ public: /// @{ static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx); - static const MCSymbolRefExpr *Create(const StringRef &Name, MCContext &Ctx); + static const MCSymbolRefExpr *Create(StringRef Name, MCContext &Ctx); /// @} /// @name Accessors diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 9e071864e6..ceb6d278c9 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -51,13 +51,13 @@ namespace llvm { /// of a syntactic one. bool IsDirective; - MCSectionCOFF(const StringRef &name, bool isDirective, SectionKind K) + MCSectionCOFF(StringRef name, bool isDirective, SectionKind K) : MCSection(K), Name(name), IsDirective(isDirective) { } public: - static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective, - SectionKind K, MCContext &Ctx); + static MCSectionCOFF *Create(StringRef Name, bool IsDirective, + SectionKind K, MCContext &Ctx); const std::string &getName() const { return Name; } bool isDirective() const { return IsDirective; } diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index 57fa903f71..4ec745fff8 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -35,13 +35,13 @@ class MCSectionELF : public MCSection { bool IsExplicit; protected: - MCSectionELF(const StringRef &Section, unsigned type, unsigned flags, + MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K, bool isExplicit) : MCSection(K), SectionName(Section.str()), Type(type), Flags(flags), IsExplicit(isExplicit) {} public: - static MCSectionELF *Create(const StringRef &Section, unsigned Type, + static MCSectionELF *Create(StringRef Section, unsigned Type, unsigned Flags, SectionKind K, bool isExplicit, MCContext &Ctx); diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h index 251c88fa94..61568194d7 100644 --- a/include/llvm/MC/MCSectionMachO.h +++ b/include/llvm/MC/MCSectionMachO.h @@ -33,7 +33,7 @@ class MCSectionMachO : public MCSection { /// size of stubs, for example. unsigned Reserved2; - MCSectionMachO(const StringRef &Segment, const StringRef &Section, + MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA, unsigned reserved2, SectionKind K) : MCSection(K), TypeAndAttributes(TAA), Reserved2(reserved2) { assert(Segment.size() <= 16 && Section.size() <= 16 && @@ -52,8 +52,8 @@ class MCSectionMachO : public MCSection { } public: - static MCSectionMachO *Create(const StringRef &Segment, - const StringRef &Section, + static MCSectionMachO *Create(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, MCContext &Ctx); diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 4d72f324b9..5febed71b0 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -155,7 +155,7 @@ namespace llvm { /// /// This is used to implement assembler directives such as .byte, .ascii, /// etc. - virtual void EmitBytes(const StringRef &Data) = 0; + virtual void EmitBytes(StringRef Data) = 0; /// EmitValue - Emit the expression @param Value into the output as a native /// integer of the given @param Size bytes. diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h index c6efe723d5..cfe04d8855 100644 --- a/include/llvm/MC/MCSymbol.h +++ b/include/llvm/MC/MCSymbol.h @@ -56,7 +56,7 @@ namespace llvm { private: // MCContext creates and uniques these. friend class MCContext; - MCSymbol(const StringRef &_Name, bool _IsTemporary) + MCSymbol(StringRef _Name, bool _IsTemporary) : Name(_Name), Section(0), Value(0), IsTemporary(_IsTemporary) {} MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 70eba68fa2..04dfb35cae 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -154,7 +154,7 @@ private: public: /// The Module constructor. Note that there is no default constructor. You /// must provide a name for the module upon construction. - explicit Module(const StringRef &ModuleID, LLVMContext& C); + explicit Module(StringRef ModuleID, LLVMContext& C); /// The module destructor. This will dropAllReferences. ~Module(); @@ -196,20 +196,20 @@ public: public: /// Set the module identifier. - void setModuleIdentifier(const StringRef &ID) { ModuleID = ID; } + void setModuleIdentifier(StringRef ID) { ModuleID = ID; } /// Set the data layout - void setDataLayout(const StringRef &DL) { DataLayout = DL; } + void setDataLayout(StringRef DL) { DataLayout = DL; } /// Set the target triple. - void setTargetTriple(const StringRef &T) { TargetTriple = T; } + void setTargetTriple(StringRef T) { TargetTriple = T; } /// Set the module-scope inline assembly blocks. - void setModuleInlineAsm(const StringRef &Asm) { GlobalScopeAsm = Asm; } + void setModuleInlineAsm(StringRef Asm) { GlobalScopeAsm = Asm; } /// Append to the module-scope inline assembly blocks, automatically /// appending a newline to the end. - void appendModuleInlineAsm(const StringRef &Asm) { + void appendModuleInlineAsm(StringRef Asm) { GlobalScopeAsm += Asm; GlobalScopeAsm += '\n'; } @@ -221,7 +221,7 @@ public: /// getNamedValue - Return the first global value in the module with /// the specified name, of arbitrary type. This method returns null /// if a global with the specified name is not found. - GlobalValue *getNamedValue(const StringRef &Name) const; + GlobalValue *getNamedValue(StringRef Name) const; /// @} /// @name Function Accessors @@ -236,10 +236,10 @@ public: /// the existing function. /// 4. Finally, the function exists but has the wrong prototype: return the /// function with a constantexpr cast to the right prototype. - Constant *getOrInsertFunction(const StringRef &Name, const FunctionType *T, + Constant *getOrInsertFunction(StringRef Name, const FunctionType *T, AttrListPtr AttributeList); - Constant *getOrInsertFunction(const StringRef &Name, const FunctionType *T); + Constant *getOrInsertFunction(StringRef Name, const FunctionType *T); /// getOrInsertFunction - Look up the specified function in the module symbol /// table. If it does not exist, add a prototype for the function and return @@ -248,21 +248,21 @@ public: /// named function has a different type. This version of the method takes a /// null terminated list of function arguments, which makes it easier for /// clients to use. - Constant *getOrInsertFunction(const StringRef &Name, + Constant *getOrInsertFunction(StringRef Name, AttrListPtr AttributeList, const Type *RetTy, ...) END_WITH_NULL; /// getOrInsertFunction - Same as above, but without the attributes. - Constant *getOrInsertFunction(const StringRef &Name, const Type *RetTy, ...) + Constant *getOrInsertFunction(StringRef Name, const Type *RetTy, ...) END_WITH_NULL; - Constant *getOrInsertTargetIntrinsic(const StringRef &Name, + Constant *getOrInsertTargetIntrinsic(StringRef Name, const FunctionType *Ty, AttrListPtr AttributeList); /// getFunction - Look up the specified function in the module symbol table. /// If it does not exist, return null. - Function *getFunction(const StringRef &Name) const; + Function *getFunction(StringRef Name) const; /// @} /// @name Global Variable Accessors @@ -272,13 +272,13 @@ public: /// symbol table. If it does not exist, return null. If AllowInternal is set /// to true, this function will return types that have InternalLinkage. By /// default, these types are not returned. - GlobalVariable *getGlobalVariable(const StringRef &Name, + GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal = false) const; /// getNamedGlobal - Return the first global variable in the module with the /// specified name, of arbitrary type. This method returns null if a global /// with the specified name is not found. - GlobalVariable *getNamedGlobal(const StringRef &Name) const { + GlobalVariable *getNamedGlobal(StringRef Name) const { return getGlobalVariable(Name, true); } @@ -289,7 +289,7 @@ public: /// with a constantexpr cast to the right type. /// 3. Finally, if the existing global is the correct delclaration, return /// the existing global. - Constant *getOrInsertGlobal(const StringRef &Name, const Type *Ty); + Constant *getOrInsertGlobal(StringRef Name, const Type *Ty); /// @} /// @name Global Alias Accessors @@ -298,7 +298,7 @@ public: /// getNamedAlias - Return the first global alias in the module with the /// specified name, of arbitrary type. This method returns null if a global /// with the specified name is not found. - GlobalAlias *getNamedAlias(const StringRef &Name) const; + GlobalAlias *getNamedAlias(StringRef Name) const; /// @} /// @name Named Metadata Accessors @@ -307,12 +307,12 @@ public: /// getNamedMetadata - Return the first NamedMDNode in the module with the /// specified name. This method returns null if a NamedMDNode with the /// specified name is not found. - NamedMDNode *getNamedMetadata(const StringRef &Name) const; + NamedMDNode *getNamedMetadata(StringRef Name) const; /// getOrInsertNamedMetadata - Return the first named MDNode in the module /// with the specified name. This method returns a new NamedMDNode if a /// NamedMDNode with the specified name is not found. - NamedMDNode *getOrInsertNamedMetadata(const StringRef &Name); + NamedMDNode *getOrInsertNamedMetadata(StringRef Name); /// @} /// @name Type Accessors @@ -321,7 +321,7 @@ public: /// addTypeName - Insert an entry in the symbol table mapping Str to Type. If /// there is already an entry for this name, true is returned and the symbol /// table is not modified. - bool addTypeName(const StringRef &Name, const Type *Ty); + bool addTypeName(StringRef Name, const Type *Ty); /// getTypeName - If there is at least one entry in the symbol table for the /// specified type, return it. @@ -329,7 +329,7 @@ public: /// getTypeByName - Return the type with the specified name in this module, or /// null if there is none by that name. - const Type *getTypeByName(const StringRef &Name) const; + const Type *getTypeByName(StringRef Name) const; /// @} /// @name Direct access to the globals list, functions list, and symbol table @@ -415,9 +415,9 @@ public: /// @brief Returns the number of items in the list of libraries. inline size_t lib_size() const { return LibraryList.size(); } /// @brief Add a library to the list of dependent libraries - void addLibrary(const StringRef &Lib); + void addLibrary(StringRef Lib); /// @brief Remove a library from the list of dependent libraries - void removeLibrary(const StringRef &Lib); + void removeLibrary(StringRef Lib); /// @brief Get all the libraries inline const LibraryListType& getLibraries() const { return LibraryList; } diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 6bef2e79b2..909ccde86a 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -167,7 +167,7 @@ public: // lookupPassInfo - Return the pass info object for the pass with the given // argument string, or null if it is not known. - static const PassInfo *lookupPassInfo(const StringRef &Arg); + static const PassInfo *lookupPassInfo(StringRef Arg); /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to /// get analysis information that might be around, for example to update it. diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index 690d080491..5864fad0d7 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -22,6 +22,7 @@ #include <vector> #include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" namespace llvm { @@ -95,7 +96,7 @@ public: // This can be useful when a pass is trivially preserved, but may not be // linked in. Be careful about spelling! // - AnalysisUsage &addPreserved(const StringRef &Arg) { + AnalysisUsage &addPreserved(StringRef Arg) { const PassInfo *PI = Pass::lookupPassInfo(Arg); // If the pass exists, preserve it. Otherwise silently do nothing. if (PI) Preserved.push_back(PI); diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 5a8f55570a..dffc24a41c 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -284,11 +284,11 @@ public: void removeNotPreservedAnalysis(Pass *P); /// Remove dead passes used by P. - void removeDeadPasses(Pass *P, const StringRef &Msg, + void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString); /// Remove P. - void freePass(Pass *P, const StringRef &Msg, + void freePass(Pass *P, StringRef Msg, enum PassDebuggingString); /// Add pass P into the PassVector. Update @@ -344,7 +344,7 @@ public: void dumpLastUses(Pass *P, unsigned Offset) const; void dumpPassArguments() const; void dumpPassInfo(Pass *P, enum PassDebuggingString S1, - enum PassDebuggingString S2, const StringRef &Msg); + enum PassDebuggingString S2, StringRef Msg); void dumpRequiredSet(const Pass *P) const; void dumpPreservedSet(const Pass *P) const; @@ -388,8 +388,8 @@ protected: bool isPassDebuggingExecutionsOrMore() const; private: - void dumpAnalysisUsage(const StringRef &Msg, const Pass *P, - const AnalysisUsage::VectorType &Set) const; + void dumpAnalysisUsage(StringRef Msg, const Pass *P, + const AnalysisUsage::VectorType &Set) const; // Set of available Analysis. This information is used while scheduling // pass. If a pass requires an analysis which is not not available then diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 66d6aaa1df..a78e81fe95 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -169,7 +169,7 @@ public: return *this; } - raw_ostream &operator<<(const StringRef &Str) { + raw_ostream &operator<<(StringRef Str) { // Inline fast path, particularly for strings with a known length. size_t Size = Str.size(); diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index 821e53783c..9a641914af 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -15,6 +15,7 @@ #ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H +#include "llvm/ADT/StringRef.h" #include "llvm/MC/SectionKind.h" namespace llvm { @@ -26,7 +27,6 @@ namespace llvm { class MCSectionMachO; class MCContext; class GlobalValue; - class StringRef; class TargetMachine; class TargetLoweringObjectFile { @@ -288,14 +288,14 @@ public: /// getMachOSection - Return the MCSection for the specified mach-o section. /// This requires the operands to be valid. - const MCSectionMachO *getMachOSection(const StringRef &Segment, - const StringRef &Section, + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, SectionKind K) const { return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); } - const MCSectionMachO *getMachOSection(const StringRef &Segment, - const StringRef &Section, + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K) const; diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 395526fa39..167e1d10d5 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -51,7 +51,7 @@ namespace llvm { typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT); typedef const MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T, - const StringRef &TT); + StringRef TT); typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T, const std::string &TT, const std::string &Features); @@ -163,7 +163,7 @@ namespace llvm { /// feature set; it should always be provided. Generally this should be /// either the target triple from the module, or the target triple of the /// host if that does not exist. - const MCAsmInfo *createAsmInfo(const StringRef &Triple) const { + const MCAsmInfo *createAsmInfo(StringRef Triple) const { if (!AsmInfoCtorFn) return 0; return AsmInfoCtorFn(*this, Triple); @@ -461,7 +461,7 @@ namespace llvm { TargetRegistry::RegisterAsmInfo(T, &Allocator); } private: - static const MCAsmInfo *Allocator(const Target &T, const StringRef &TT) { + static const MCAsmInfo *Allocator(const Target &T, StringRef TT) { return new MCAsmInfoImpl(T, TT); } diff --git a/include/llvm/TypeSymbolTable.h b/include/llvm/TypeSymbolTable.h index d84196f05e..26b1dbf2df 100644 --- a/include/llvm/TypeSymbolTable.h +++ b/include/llvm/TypeSymbolTable.h @@ -58,26 +58,26 @@ public: /// incrementing an integer and appending it to the name, if necessary /// @returns the unique name /// @brief Get a unique name for a type - std::string getUniqueName(const StringRef &BaseName) const; + std::string getUniqueName(StringRef BaseName) const; /// This method finds the type with the given \p name in the type map /// and returns it. /// @returns null if the name is not found, otherwise the Type /// associated with the \p name. /// @brief Lookup a type by name. - Type *lookup(const StringRef &name) const; + Type *lookup(StringRef name) const; /// Lookup the type associated with name. /// @returns end() if the name is not found, or an iterator at the entry for /// Type. - iterator find(const StringRef &Name) { + iterator find(StringRef Name) { return tmap.find(Name); } /// Lookup the type associated with name. /// @returns end() if the name is not found, or an iterator at the entry for /// Type. - const_iterator find(const StringRef &Name) const { + const_iterator find(StringRef Name) const { return tmap.find(Name); } @@ -119,7 +119,7 @@ public: /// a many-to-one mapping between names and types. This method allows a type /// with an existing entry in the symbol table to get a new name. /// @brief Insert a type under a new name. - void insert(const StringRef &Name, const Type *Typ); + void insert(StringRef Name, const Type *Typ); /// Remove a type at the specified position in the symbol table. /// @returns the removed Type. diff --git a/include/llvm/ValueSymbolTable.h b/include/llvm/ValueSymbolTable.h index b147c1e213..e05fdbd08d 100644 --- a/include/llvm/ValueSymbolTable.h +++ b/include/llvm/ValueSymbolTable.h @@ -69,7 +69,7 @@ public: /// the symbol table. /// @returns the value associated with the \p Name /// @brief Lookup a named Value. - Value *lookup(const StringRef &Name) const { return vmap.lookup(Name); } + Value *lookup(StringRef Name) const { return vmap.lookup(Name); } /// @returns true iff the symbol table is empty /// @brief Determine if the symbol table is empty @@ -112,7 +112,7 @@ private: /// createValueName - This method attempts to create a value name and insert /// it into the symbol table with the specified name. If it conflicts, it /// auto-renames the name and returns that instead. - ValueName *createValueName(const StringRef &Name, Value *V); + ValueName *createValueName(StringRef Name, Value *V); /// This method removes a value from the symbol table. It leaves the /// ValueName attached to the value, but it is no longer inserted in the |