forked from OSchip/llvm-project
[clang-tidy] Fix bug in modernize-loop-convert check.
http://reviews.llvm.org/D12186 Patch by Angel Garcia! llvm-svn: 245561
This commit is contained in:
parent
66be61ad4f
commit
74a44d9133
|
@ -337,8 +337,9 @@ static StringRef getStringFromRange(SourceManager &SourceMgr,
|
|||
const LangOptions &LangOpts,
|
||||
SourceRange Range) {
|
||||
if (SourceMgr.getFileID(Range.getBegin()) !=
|
||||
SourceMgr.getFileID(Range.getEnd()))
|
||||
return nullptr;
|
||||
SourceMgr.getFileID(Range.getEnd())) {
|
||||
return StringRef(); // Empty string.
|
||||
}
|
||||
|
||||
return Lexer::getSourceText(CharSourceRange(Range, true), SourceMgr,
|
||||
LangOpts);
|
||||
|
|
|
@ -176,4 +176,15 @@ struct RValueDerefContainer {
|
|||
iterator begin() const;
|
||||
iterator end() const;
|
||||
};
|
||||
|
||||
namespace Macros {
|
||||
|
||||
struct MacroStruct {
|
||||
int arr[10];
|
||||
};
|
||||
static MacroStruct *MacroSt;
|
||||
#define CONT MacroSt->
|
||||
|
||||
} // namespace Macros
|
||||
|
||||
#endif // STRUCTURES_H
|
||||
|
|
|
@ -605,4 +605,25 @@ void different_type() {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace SingleIterator
|
||||
|
||||
|
||||
namespace Macros {
|
||||
|
||||
const int N = 10;
|
||||
int arr[N];
|
||||
|
||||
void messing_with_macros() {
|
||||
for (int i = 0; i < N; ++i) {
|
||||
printf("Value: %d\n", arr[i]);
|
||||
}
|
||||
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
|
||||
// CHECK-FIXES: for (auto & elem : arr) {
|
||||
// CHECK-FIXES-NEXT: printf("Value: %d\n", elem);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
printf("Value: %d\n", CONT arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Macros
|
||||
|
|
Loading…
Reference in New Issue