From: Craig Topper Date: Sat, 30 Aug 2014 16:55:52 +0000 (+0000) Subject: Fix some cases where StringRef was being passed by const reference. Remove const... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b9bebfdedb7c2a50dfa74a03abac416594d7de9;p=clang Fix some cases where StringRef was being passed by const reference. Remove const from some other StringRefs since its implicitly const already. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216825 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 9dd6f49eba..817d325075 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1558,7 +1558,7 @@ AST_MATCHER_P(NamedDecl, matchesName, std::string, RegExp) { inline internal::PolymorphicMatcherWithParam1< internal::HasOverloadedOperatorNameMatcher, StringRef, AST_POLYMORPHIC_SUPPORTED_TYPES_2(CXXOperatorCallExpr, FunctionDecl)> -hasOverloadedOperatorName(const StringRef Name) { +hasOverloadedOperatorName(StringRef Name) { return internal::PolymorphicMatcherWithParam1< internal::HasOverloadedOperatorNameMatcher, StringRef, AST_POLYMORPHIC_SUPPORTED_TYPES_2(CXXOperatorCallExpr, FunctionDecl)>( diff --git a/include/clang/Analysis/Analyses/ThreadSafetyTIL.h b/include/clang/Analysis/Analyses/ThreadSafetyTIL.h index 4b7b092708..8e244f99a7 100644 --- a/include/clang/Analysis/Analyses/ThreadSafetyTIL.h +++ b/include/clang/Analysis/Analyses/ThreadSafetyTIL.h @@ -378,7 +378,7 @@ public: VariableKind kind() const { return static_cast(Flags); } - const StringRef name() const { return Name; } + StringRef name() const { return Name; } const clang::ValueDecl *clangDecl() const { return Cvdecl; } // Returns the definition (for let vars) or type (for parameter & self vars) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 856fa6cd9c..cada46c48b 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -7213,10 +7213,10 @@ public: }; llvm::StringMap SectionInfos; - bool UnifySection(const StringRef &SectionName, + bool UnifySection(StringRef SectionName, int SectionFlags, DeclaratorDecl *TheDecl); - bool UnifySection(const StringRef &SectionName, + bool UnifySection(StringRef SectionName, int SectionFlags, SourceLocation PragmaSectionLocation); diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 54a0fb4541..ec8006578f 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -179,9 +179,9 @@ public: const ExplodedNode *getErrorNode() const { return ErrorNode; } - const StringRef getDescription() const { return Description; } + StringRef getDescription() const { return Description; } - const StringRef getShortDescription(bool UseFallback = true) const { + StringRef getShortDescription(bool UseFallback = true) const { if (ShortDescription.empty() && UseFallback) return Description; return ShortDescription; diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp index 792a832044..06a08bdad4 100644 --- a/lib/AST/CommentLexer.cpp +++ b/lib/AST/CommentLexer.cpp @@ -362,7 +362,7 @@ void Lexer::lexCommentText(Token &T) { } } - const StringRef CommandName(BufferPtr + 1, Length); + StringRef CommandName(BufferPtr + 1, Length); const CommandInfo *Info = Traits.getCommandInfoOrNULL(CommandName); if (!Info) { @@ -531,7 +531,7 @@ void Lexer::lexVerbatimLineText(Token &T) { // Extract current line. const char *Newline = findNewline(BufferPtr, CommentEnd); - const StringRef Text(BufferPtr, Newline - BufferPtr); + StringRef Text(BufferPtr, Newline - BufferPtr); formTokenWithChars(T, Newline, tok::verbatim_line_text); T.setVerbatimLineText(Text); diff --git a/lib/ASTMatchers/Dynamic/Marshallers.h b/lib/ASTMatchers/Dynamic/Marshallers.h index 75e3a93d4c..bab0adb2c8 100644 --- a/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/lib/ASTMatchers/Dynamic/Marshallers.h @@ -473,7 +473,7 @@ private: template inline void collect(FromTypeList); - const StringRef Name; + StringRef Name; std::vector &Out; }; diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 0d47b09410..6450406453 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -111,7 +111,7 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, // that we are in an inconsistent situation and error out as quickly as // possible. if (!Buffer.getPointer()) { - const StringRef FillStr("<<>>\n"); + StringRef FillStr("<<>>\n"); Buffer.setPointer(MemoryBuffer::getNewMemBuffer(ContentsEntry->getSize(), "").release()); char *Ptr = const_cast(Buffer.getPointer()->getBufferStart()); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 619a66ab4a..562bbef354 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -391,8 +391,8 @@ private: /// /// This structure is used by both classes and categories, and contains a next /// pointer allowing them to be chained together in a linked list. - llvm::Constant *GenerateMethodList(const StringRef &ClassName, - const StringRef &CategoryName, + llvm::Constant *GenerateMethodList(StringRef ClassName, + StringRef CategoryName, ArrayRef MethodSels, ArrayRef MethodTypes, bool isClassMethodList); @@ -875,8 +875,8 @@ void CGObjCGNU::EmitClassRef(const std::string &className) { llvm::GlobalValue::WeakAnyLinkage, ClassSymbol, symbolRef); } -static std::string SymbolNameForMethod(const StringRef &ClassName, - const StringRef &CategoryName, const Selector MethodName, +static std::string SymbolNameForMethod( StringRef ClassName, + StringRef CategoryName, const Selector MethodName, bool isClassMethod) { std::string MethodNameColonStripped = MethodName.getAsString(); std::replace(MethodNameColonStripped.begin(), MethodNameColonStripped.end(), @@ -1463,8 +1463,8 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, /// Generates a MethodList. Used in construction of a objc_class and /// objc_category structures. llvm::Constant *CGObjCGNU:: -GenerateMethodList(const StringRef &ClassName, - const StringRef &CategoryName, +GenerateMethodList(StringRef ClassName, + StringRef CategoryName, ArrayRef MethodSels, ArrayRef MethodTypes, bool isClassMethodList) { diff --git a/lib/CodeGen/SanitizerBlacklist.cpp b/lib/CodeGen/SanitizerBlacklist.cpp index 9f1ddc8e7d..9882a6dc41 100644 --- a/lib/CodeGen/SanitizerBlacklist.cpp +++ b/lib/CodeGen/SanitizerBlacklist.cpp @@ -31,7 +31,7 @@ static StringRef GetGlobalTypeString(const llvm::GlobalValue &G) { } bool SanitizerBlacklist::isIn(const llvm::Module &M, - const StringRef Category) const { + StringRef Category) const { return SCL->inSection("src", M.getModuleIdentifier(), Category); } @@ -41,7 +41,7 @@ bool SanitizerBlacklist::isIn(const llvm::Function &F) const { } bool SanitizerBlacklist::isIn(const llvm::GlobalVariable &G, - const StringRef Category) const { + StringRef Category) const { return isIn(*G.getParent(), Category) || SCL->inSection("global", G.getName(), Category) || SCL->inSection("type", GetGlobalTypeString(G), Category); diff --git a/lib/CodeGen/SanitizerBlacklist.h b/lib/CodeGen/SanitizerBlacklist.h index e890c5c57d..44237ad533 100644 --- a/lib/CodeGen/SanitizerBlacklist.h +++ b/lib/CodeGen/SanitizerBlacklist.h @@ -34,10 +34,10 @@ class SanitizerBlacklist { public: SanitizerBlacklist(llvm::SpecialCaseList *SCL) : SCL(SCL) {} bool isIn(const llvm::Module &M, - const StringRef Category = StringRef()) const; + StringRef Category = StringRef()) const; bool isIn(const llvm::Function &F) const; bool isIn(const llvm::GlobalVariable &G, - const StringRef Category = StringRef()) const; + StringRef Category = StringRef()) const; bool isBlacklistedType(StringRef MangledTypeName) const; }; } // end namespace CodeGen diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 0697285473..a14b8894d2 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -233,8 +233,8 @@ void Compilation::initCompilationForDiagnostics() { // Redirect stdout/stderr to /dev/null. Redirects = new const StringRef*[3](); Redirects[0] = nullptr; - Redirects[1] = new const StringRef(); - Redirects[2] = new const StringRef(); + Redirects[1] = new StringRef(); + Redirects[2] = new StringRef(); } StringRef Compilation::getSysRoot() const { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index d751ca9a11..df2f9cfa4c 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1637,7 +1637,7 @@ void Clang::AddHexagonTargetArgs(const ArgList &Args, } // Decode AArch64 features from string like +[no]featureA+[no]featureB+... -static bool DecodeAArch64Features(const Driver &D, const StringRef &text, +static bool DecodeAArch64Features(const Driver &D, StringRef text, std::vector &Features) { SmallVector Split; text.split(Split, StringRef("+"), -1, false); @@ -2134,7 +2134,7 @@ static void addProfileRT( } static SmallString<128> getSanitizerRTLibName(const ToolChain &TC, - const StringRef Sanitizer, + StringRef Sanitizer, bool Shared) { // Sanitizer runtime has name "libclang_rt.-.{a,so}" // (or "libclang_rt.--android.so for Android) @@ -2150,7 +2150,7 @@ static SmallString<128> getSanitizerRTLibName(const ToolChain &TC, static void addSanitizerRTLinkFlags(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs, - const StringRef Sanitizer, + StringRef Sanitizer, bool ExportSymbols, bool LinkDeps) { SmallString<128> LibSanitizer = getSanitizerRTLibName(TC, Sanitizer, /*Shared*/ false); @@ -7765,7 +7765,7 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, static void addSanitizerRTWindows(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs, - const StringRef RTName) { + StringRef RTName) { SmallString<128> LibSanitizer(getCompilerRTLibDir(TC)); llvm::sys::path::append(LibSanitizer, Twine("clang_rt.") + RTName + ".lib"); @@ -7863,7 +7863,7 @@ static std::string FindFallback(const char *FallbackName, llvm::SplitString(OptPath.getValue(), PathSegments, EnvPathSeparatorStr); for (size_t i = 0, e = PathSegments.size(); i != e; ++i) { - const StringRef &PathSegment = PathSegments[i]; + StringRef PathSegment = PathSegments[i]; if (PathSegment.empty()) continue; diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index a7d606d545..6320faab37 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -360,7 +360,7 @@ void Sema::PragmaStack::Act(SourceLocation PragmaLocation, } } -bool Sema::UnifySection(const StringRef &SectionName, +bool Sema::UnifySection(StringRef SectionName, int SectionFlags, DeclaratorDecl *Decl) { auto Section = SectionInfos.find(SectionName); @@ -387,7 +387,7 @@ bool Sema::UnifySection(const StringRef &SectionName, return false; } -bool Sema::UnifySection(const StringRef &SectionName, +bool Sema::UnifySection(StringRef SectionName, int SectionFlags, SourceLocation PragmaSectionLocation) { auto Section = SectionInfos.find(SectionName); diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index aa3e89ed67..b81b60c802 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -615,7 +615,7 @@ bool ObjCPropertyOpBuilder::findSetter(bool warn) { if (setter->isPropertyAccessor() && warn) if (const ObjCInterfaceDecl *IFace = dyn_cast(setter->getDeclContext())) { - const StringRef thisPropertyName(prop->getName()); + StringRef thisPropertyName = prop->getName(); // Try flipping the case of the first character. char front = thisPropertyName.front(); front = isLowercase(front) ? toUppercase(front) : toLowercase(front);