diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-20 18:59:05 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-11-20 18:59:05 +0000 |
commit | 377748fd7bbf5798fe54a032e79d61c6feb86ccb (patch) | |
tree | 8298c4ed3e634a03ec25c5d4d3cc199ce30c9bc0 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | 4b0b84f4bb9044b61ba61816104356234ad1eef7 (diff) | |
download | llvm-377748fd7bbf5798fe54a032e79d61c6feb86ccb.zip llvm-377748fd7bbf5798fe54a032e79d61c6feb86ccb.tar.gz llvm-377748fd7bbf5798fe54a032e79d61c6feb86ccb.tar.bz2 |
[clang][Parse] Diagnose useless null statements / empty init-statements
Summary:
clang has `-Wextra-semi` (D43162), which is not dictated by the currently selected standard.
While that is great, there is at least one more source of need-less semis - 'null statements'.
Sometimes, they are needed:
```
for(int x = 0; continueToDoWork(x); x++)
; // Ugly code, but the semi is needed here.
```
But sometimes they are just there for no reason:
```
switch(X) {
case 0:
return -2345;
case 5:
return 0;
default:
return 42;
}; // <- oops
;;;;;;;;;;; <- OOOOPS, still not diagnosed. Clearly this is junk.
```
Additionally:
```
if(; // <- empty init-statement
true)
;
switch (; // empty init-statement
x) {
...
}
for (; // <- empty init-statement
int y : S())
;
}
As usual, things may or may not go sideways in the presence of macros.
While evaluating this diag on my codebase of interest, it was unsurprisingly
discovered that Google Test macros are *very* prone to this.
And it seems many issues are deep within the GTest itself, not
in the snippets passed from the codebase that uses GTest.
So after some thought, i decided not do issue a diagnostic if the semi
is within *any* macro, be it either from the normal header, or system header.
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]]
Reviewers: rsmith, aaron.ballman, efriedma
Reviewed By: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D52695
llvm-svn: 347339
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
0 files changed, 0 insertions, 0 deletions