LoopConvert no longer take as alias references to other containers.

Summary: Fix a bug where modernize-loop-convert check would take as alias a reference to other containers. Add the pertinent test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D12361

llvm-svn: 246034
This commit is contained in:
Angel Garcia Gomez 2015-08-26 14:51:11 +00:00
parent 9f4709b261
commit 446fe8d62c
2 changed files with 11 additions and 1 deletions

View File

@ -363,7 +363,7 @@ static bool isAliasDecl(const Decl *TheDecl, const VarDecl *IndexVar) {
return isDereferenceOfOpCall(OpCall, IndexVar);
if (OpCall->getOperator() == OO_Subscript) {
assert(OpCall->getNumArgs() == 2);
return true;
return isIndexInSubscriptExpr(OpCall->getArg(1), IndexVar);
}
break;
}

View File

@ -202,6 +202,16 @@ void refs_and_vals() {
// CHECK-FIXES-NOT: MutableVal &{{[a-z_]+}} =
// CHECK-FIXES: {}
// CHECK-FIXES-NEXT: alias.x = 0;
dependent<int> dep, other;
for (dependent<int>::iterator it = dep.begin(), e = dep.end(); it != e; ++it) {
printf("%d\n", *it);
const int& idx = other[0];
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : dep)
// CHECK-FIXES-NEXT: printf("%d\n", elem);
// CHECK-FIXES-NEXT: const int& idx = other[0];
}
} // namespace NamingAlias