Author: alexfh Date: Wed Aug 19 11:54:51 2015 New Revision: 245458 URL: http://llvm.org/viewvc/llvm-project?rev=245458&view=rev Log: [clang-tidy] Fix LoopConvertCheck bug.
Fix LoopConvertCheck bug: StringRef to temporaries. Also add LLVM_ATTRIBUTE_UNUSED to ModernizeModuleAnchorDestination. http://reviews.llvm.org/D12157 Patch by Angel Garcia! Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=245458&r1=245457&r2=245458&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed Aug 19 11:54:51 2015 @@ -417,7 +417,7 @@ void LoopConvertCheck::doConversion( // First, replace all usages of the array subscript expression with our new // variable. for (const auto &I : Usages) { - StringRef ReplaceText = I.IsArrow ? VarName + "." : VarName; + std::string ReplaceText = I.IsArrow ? VarName + "." : VarName; TUInfo->getReplacedVars().insert(std::make_pair(TheLoop, IndexVar)); Diag << FixItHint::CreateReplacement( CharSourceRange::getTokenRange(I.Range), ReplaceText); @@ -446,11 +446,9 @@ void LoopConvertCheck::doConversion( } StringRef MaybeDereference = ContainerNeedsDereference ? "*" : ""; - StringRef TypeString = AutoRefType.getAsString(); - StringRef Range = ("(" + TypeString + " " + VarName + " : " + - MaybeDereference + ContainerString + ")") - .str(); - + std::string TypeString = AutoRefType.getAsString(); + std::string Range = ("(" + TypeString + " " + VarName + " : " + + MaybeDereference + ContainerString + ")").str(); Diag << FixItHint::CreateReplacement( CharSourceRange::getTokenRange(ParenRange), Range); TUInfo->getGeneratedDecls().insert(make_pair(TheLoop, VarName)); Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=245458&r1=245457&r2=245458&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Wed Aug 19 11:54:51 2015 @@ -347,23 +347,28 @@ static int clangTidyMain(int argc, const // This anchor is used to force the linker to link the LLVMModule. extern volatile int LLVMModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = LLVMModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = + LLVMModuleAnchorSource; // This anchor is used to force the linker to link the GoogleModule. extern volatile int GoogleModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination = GoogleModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination = + GoogleModuleAnchorSource; // This anchor is used to force the linker to link the MiscModule. extern volatile int MiscModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination = MiscModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination = + MiscModuleAnchorSource; // This anchor is used to force the linker to link the ModernizeModule. extern volatile int ModernizeModuleAnchorSource; -static int ModernizeModuleAnchorDestination = ModernizeModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination = + ModernizeModuleAnchorSource; // This anchor is used to force the linker to link the ReadabilityModule. extern volatile int ReadabilityModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination = ReadabilityModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination = + ReadabilityModuleAnchorSource; } // namespace tidy } // namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits