[PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 26 04:35:57 PST 2016
alexfh added a comment.
In http://reviews.llvm.org/D16535#362685, @omtcyf0 wrote:
> @xazax.hun did you actually run the tool on the LLVM codebase?
>
> Because this check generates **tons** of false-positive reports during codebase analysis.
>
> See the minimal example below.
>
> omtcyf0-laptop:playground omtcyf0$ cat main.cpp
> #include <vector>
>
> int main() {
> std::vector<int> numbers = {1, 2, 3, 4, 5, 6};
> for (std::vector<int>::iterator it = std::begin(numbers),
> end = std::end(numbers);
> it != end; ++it) {
> (*it)++;
> }
> return 0;
> }
> omtcyf0-laptop:playground omtcyf0$ /Users/omtcyf0/Documents/dev/build/Release/llvm/bin/clang-tidy -checks=misc-suspicious-semicolon main.cpp
> Error while trying to load a compilation database:
> Could not auto-detect compilation database for file "main.cpp"
> No compilation database found in /Users/omtcyf0/Documents/dev/playground or any parent directory
> json-compilation-database: Error while opening JSON database: No such file or directory
> Running without flags.
> 1 warning and 1 error generated.
> Error while processing /Users/omtcyf0/Documents/dev/playground/main.cpp.
> /Users/omtcyf0/Documents/dev/playground/main.cpp:6:17: warning: potentially unintended semicolon [misc-suspicious-semicolon]
> it != end; ++it) {
> ^
> /usr/include/wchar.h:89:10: error: 'stdarg.h' file not found [clang-diagnostic-error]
> #include <stdarg.h>
> ^
>
>
> And this is happening all over the LLVM codebase, because there is nothing bad there.
>
> Can you please fix that?
Kirill, the problem in your case may be related to the check seeing incomplete AST due to compilation errors. Can you append `-- -std=c++11` to your clang-tidy invocation and try again whether it will be able to parse the file completely (i.e. without any "file not found" and other compilation errors)?
Repository:
rL LLVM
http://reviews.llvm.org/D16535
More information about the cfe-commits
mailing list