[PATCH] D12157: Fix LoopConvertCheck bug.
Angel Garcia via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 19 09:48:00 PDT 2015
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: klimek, cfe-commits.
angelgarcia changed the visibility of this Differential Revision from "Public (No Login Required)" to "All Users".
Fix LoopConvertCheck bug: StringRef to temporaries.
http://reviews.llvm.org/D12157
Files:
clang-tidy/modernize/LoopConvertCheck.cpp
clang-tidy/tool/ClangTidyMain.cpp
Index: clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -359,7 +359,7 @@
// 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;
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -417,7 +417,7 @@
// 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 @@
}
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12157.32566.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150819/93c9a6d2/attachment.bin>
More information about the cfe-commits
mailing list