forked from OSchip/llvm-project
Avoid LoopConvertCheck replacements in template instantiations.
Summary: Prevent LoopConvertCheck from doing replacements in template instantiations, and add a test. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D12321 llvm-svn: 245942
This commit is contained in:
parent
d3ef1083c3
commit
06d010cae3
|
@ -70,6 +70,7 @@ StatementMatcher makeArrayLoopMatcher() {
|
|||
expr(hasType(isInteger())).bind(ConditionBoundName);
|
||||
|
||||
return forStmt(
|
||||
unless(isInTemplateInstantiation()),
|
||||
hasLoopInit(declStmt(hasSingleDecl(InitToZeroMatcher))),
|
||||
hasCondition(anyOf(
|
||||
binaryOperator(hasOperatorName("<"),
|
||||
|
@ -159,6 +160,7 @@ StatementMatcher makeIteratorLoopMatcher() {
|
|||
.bind(DerefByRefResultName)))))));
|
||||
|
||||
return forStmt(
|
||||
unless(isInTemplateInstantiation()),
|
||||
hasLoopInit(anyOf(declStmt(declCountIs(2),
|
||||
containsDeclaration(0, InitDeclMatcher),
|
||||
containsDeclaration(1, EndDeclMatcher)),
|
||||
|
@ -258,6 +260,7 @@ StatementMatcher makePseudoArrayLoopMatcher() {
|
|||
EndInitMatcher));
|
||||
|
||||
return forStmt(
|
||||
unless(isInTemplateInstantiation()),
|
||||
hasLoopInit(
|
||||
anyOf(declStmt(declCountIs(2),
|
||||
containsDeclaration(0, InitToZeroMatcher),
|
||||
|
|
|
@ -626,3 +626,24 @@ void messing_with_macros() {
|
|||
}
|
||||
|
||||
} // 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) {
|
||||
}
|
||||
S s;
|
||||
for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
|
||||
}
|
||||
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
|
||||
// CHECK-FIXES: for (auto & elem : s) {
|
||||
}
|
||||
|
||||
void template_instantiation() {
|
||||
S a;
|
||||
set_union(a);
|
||||
}
|
||||
|
||||
} // namespace Templates
|
||||
|
|
Loading…
Reference in New Issue