Author: yrnkrn Date: Fri Jul 3 00:09:59 2015 New Revision: 241319 URL: http://llvm.org/viewvc/llvm-project?rev=241319&view=rev Log: Replace some const std::string & with llvm::StringRef or std::string and std::move to avoid implicit std::string construction.
Part 1/2. Patch by Eugene Kosov. Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h cfe/trunk/include/clang/Frontend/CompilerInstance.h cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp cfe/trunk/lib/Frontend/CompilerInstance.cpp Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Jul 3 00:09:59 2015 @@ -112,7 +112,7 @@ private: /// /// FIXME: Do we want to support this now that we have bind()? template <typename T> -internal::Matcher<T> id(const std::string &ID, +internal::Matcher<T> id(StringRef ID, const internal::BindableMatcher<T> &InnerMatcher) { return InnerMatcher.bind(ID); } Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Fri Jul 3 00:09:59 2015 @@ -140,8 +140,7 @@ public: }; /// \brief Add a binding from an id to a node. - void setBinding(const std::string &Id, - const ast_type_traits::DynTypedNode &DynNode) { + void setBinding(StringRef Id, const ast_type_traits::DynTypedNode &DynNode) { if (Bindings.empty()) Bindings.emplace_back(); for (BoundNodesMap &Binding : Bindings) Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original) +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Fri Jul 3 00:09:59 2015 @@ -242,7 +242,7 @@ struct VariantMatcher::TypedMatcherOps f /// /// Supported types: /// - \c unsigned -/// - \c std::string +/// - \c llvm::StringRef /// - \c VariantMatcher (\c DynTypedMatcher / \c Matcher<T>) class VariantValue { public: @@ -254,7 +254,7 @@ public: /// \brief Specific constructors for each supported type. VariantValue(unsigned Unsigned); - VariantValue(const std::string &String); + VariantValue(StringRef String); VariantValue(const VariantMatcher &Matchers); /// \brief Returns true iff this is not an empty value. @@ -269,7 +269,7 @@ public: /// \brief String value functions. bool isString() const; const std::string &getString() const; - void setString(const std::string &String); + void setString(StringRef String); /// \brief Matcher value functions. bool isMatcher() const; Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original) +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Jul 3 00:09:59 2015 @@ -157,9 +157,10 @@ class CompilerInstance : public ModuleLo std::string TempFilename; std::unique_ptr<raw_ostream> OS; - OutputFile(const std::string &filename, const std::string &tempFilename, + OutputFile(std::string filename, std::string tempFilename, std::unique_ptr<raw_ostream> OS) - : Filename(filename), TempFilename(tempFilename), OS(std::move(OS)) {} + : Filename(std::move(filename)), TempFilename(std::move(tempFilename)), + OS(std::move(OS)) {} OutputFile(OutputFile &&O) : Filename(std::move(O.Filename)), TempFilename(std::move(O.TempFilename)), OS(std::move(O.OS)) {} @@ -614,7 +615,7 @@ public: /// /// \return - The new object on success, or null on failure. static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource( - StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, + StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerOperations &PCHContainerOps, void *DeserializationListener, bool OwnDeserializationListener, @@ -627,11 +628,9 @@ public: /// Create a code completion consumer to print code completion results, at /// \p Filename, \p Line, and \p Column, to the given output stream \p OS. - static CodeCompleteConsumer * - createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename, - unsigned Line, unsigned Column, - const CodeCompleteOptions &Opts, - raw_ostream &OS); + static CodeCompleteConsumer *createCodeCompletionConsumer( + Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column, + const CodeCompleteOptions &Opts, raw_ostream &OS); /// \brief Create the Sema object to be used for parsing. void createSema(TranslationUnitKind TUKind, Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original) +++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Fri Jul 3 00:09:59 2015 @@ -216,7 +216,7 @@ private: if (Code[Length] == Marker) { Result->Kind = TokenInfo::TK_Literal; Result->Text = Code.substr(0, Length + 1); - Result->Value = Code.substr(1, Length - 1).str(); + Result->Value = Code.substr(1, Length - 1); Code = Code.drop_front(Length + 1); return; } Modified: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp (original) +++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp Fri Jul 3 00:09:59 2015 @@ -249,7 +249,7 @@ VariantValue::VariantValue(unsigned Unsi setUnsigned(Unsigned); } -VariantValue::VariantValue(const std::string &String) : Type(VT_Nothing) { +VariantValue::VariantValue(StringRef String) : Type(VT_Nothing) { setString(String); } @@ -319,7 +319,7 @@ const std::string &VariantValue::getStri return *Value.String; } -void VariantValue::setString(const std::string &NewValue) { +void VariantValue::setString(StringRef NewValue) { reset(); Type = VT_String; Value.String = new std::string(NewValue); Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=241319&r1=241318&r2=241319&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Jul 3 00:09:59 2015 @@ -405,7 +405,7 @@ void CompilerInstance::createPCHExternal } IntrusiveRefCntPtr<ASTReader> CompilerInstance::createPCHExternalASTSource( - StringRef Path, const std::string &Sysroot, bool DisablePCHValidation, + StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerOperations &PCHContainerOps, void *DeserializationListener, bool OwnDeserializationListener, @@ -413,7 +413,7 @@ IntrusiveRefCntPtr<ASTReader> CompilerIn HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); IntrusiveRefCntPtr<ASTReader> Reader(new ASTReader( - PP, Context, PCHContainerOps, Sysroot.empty() ? "" : Sysroot.c_str(), + PP, Context, PCHContainerOps, Sysroot.empty() ? "" : Sysroot.data(), DisablePCHValidation, AllowPCHWithCompilerErrors, /*AllowConfigurationMismatch*/ false, HSOpts.ModulesValidateSystemHeaders, UseGlobalModuleIndex)); @@ -502,7 +502,7 @@ void CompilerInstance::createFrontendTim CodeCompleteConsumer * CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP, - const std::string &Filename, + StringRef Filename, unsigned Line, unsigned Column, const CodeCompleteOptions &Opts, _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits