[PATCH] D12321: Avoid LoopConvertCheck replacements in template instantiations.
Angel Garcia via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 25 07:50:13 PDT 2015
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: cfe-commits, klimek.
Prevent LoopConvertCheck from doing replacements in template instantiations, and add a test.
http://reviews.llvm.org/D12321
Files:
clang-tidy/modernize/LoopConvertCheck.cpp
test/clang-tidy/modernize-loop-convert-extra.cpp
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===================================================================
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -626,3 +626,19 @@
}
} // namespace Macros
+
+namespace Templates {
+
+template <class Container>
+void set_union(Container &container) {
+ for (typename Container::const_iterator SI = container.begin(),
+ SE = container.end(); SI != SE; ++SI) {
+ }
+}
+
+void template_instantiation() {
+ S a;
+ set_union(a);
+}
+
+} // namespace Templates
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -70,6 +70,7 @@
expr(hasType(isInteger())).bind(ConditionBoundName);
return forStmt(
+ unless(isInTemplateInstantiation()),
hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
hasCondition(anyOf(
binaryOperator(hasOperatorName("<"),
@@ -159,6 +160,7 @@
.bind(DerefByRefResultName)))))));
return forStmt(
+ unless(isInTemplateInstantiation()),
hasLoopInit(anyOf(declStmt(declCountIs(2),
containsDeclaration(0, InitDeclMatcher),
containsDeclaration(1, EndDeclMatcher)),
@@ -258,6 +260,7 @@
EndInitMatcher));
return forStmt(
+ unless(isInTemplateInstantiation()),
hasLoopInit(
anyOf(declStmt(declCountIs(2),
containsDeclaration(0, InitToZeroMatcher),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12321.33079.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150825/c634b711/attachment.bin>
More information about the cfe-commits
mailing list