Commit Graph

1708 Commits

Author SHA1 Message Date
Mads Ravn dfa3b3d3ee Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270472
2016-05-23 18:15:40 +00:00
Mads Ravn d01743a3f7 Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270470
2016-05-23 18:06:29 +00:00
Alexander Kornienko 1c6d827015 Fix docs
llvm-svn: 270288
2016-05-20 22:42:03 +00:00
Alexander Kornienko 5d08bb72d9 [clang-tidy] Switch to a more common way of customizing check behavior.
This should have been done this way from the start, however I somehow missed
r257177.

llvm-svn: 270215
2016-05-20 13:42:40 +00:00
Haojian Wu cc0c10e300 [find-all-symbols] Some cleanups in unittest.
llvm-svn: 270211
2016-05-20 12:47:56 +00:00
Haojian Wu a23ac3d249 [find-all-symbol] Ignore inline namespace context.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270206
2016-05-20 12:04:56 +00:00
Miklos Vajna ed28d41b1a clang-rename: fix renaming members when referenced as macro arguments
The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y).

Reviewers: klimek

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

llvm-svn: 270204
2016-05-20 11:43:59 +00:00
Eric Liu 6c9472c57f [find-all-symbols] fix failing unittest for Windows build bot.
llvm-svn: 270202
2016-05-20 11:14:36 +00:00
Haojian Wu 20dec208e9 [find-all-symbol] Try to fix the failure windows unittest.
llvm-svn: 270199
2016-05-20 10:36:53 +00:00
Haojian Wu 17baf85e41 [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 270197
2016-05-20 09:38:25 +00:00
Eric Liu 81554e7257 [find-all-symbols] fixed FindAllMacros compilation error.
llvm-svn: 270196
2016-05-20 09:23:19 +00:00
Eric Liu 83a4d7fbba [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and FindAllMacros.
llvm-svn: 270193
2016-05-20 09:12:01 +00:00
Haojian Wu 1cea6e5531 [clang-tidy] Handle using-decls with more than one shadow decl.
Reviewers: alexfh

Subscribers: cfe-commits, djasper

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

llvm-svn: 270191
2016-05-20 08:34:32 +00:00
Haojian Wu 5e4f0255a1 [find-all-symbol] Add macro support.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270189
2016-05-20 08:04:36 +00:00
Benjamin Kramer ee4e522c26 [include-fixer] Fix unused variable warning in Release builds.
llvm-svn: 270082
2016-05-19 16:57:57 +00:00
Haojian Wu 0de7226236 [include-fixer] Remove an unused local variable ExistingHeaders.
llvm-svn: 270059
2016-05-19 13:23:27 +00:00
Benjamin Kramer 9b15b6f2d7 [include-fixer] Make search handle fully qualified names correctly.
If a search string starts with "::" we don't want to return any results
for suffixes of that string.

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

llvm-svn: 270055
2016-05-19 12:41:56 +00:00
Benjamin Kramer 04666a2d5d [include-fixer] Remove obsolete windows hack.
llvm-svn: 270045
2016-05-19 11:39:56 +00:00
Alexander Kornienko a20bab46cd [clang-tidy] Fix/add style guide links.
Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)!

llvm-svn: 270033
2016-05-19 09:31:30 +00:00
Alexander Kornienko 77c8b2ed9f [clang-tidy] Fix doc titles.
llvm-svn: 270032
2016-05-19 09:29:46 +00:00
Eric Liu 702cfd1b2b [include-fixer] Sort headers after inserting new headers.
Summary: [include-fixer] Sort headers after inserting new headers.

Reviewers: bkramer

Subscribers: klimek, djasper, hokein, cfe-commits

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

llvm-svn: 270031
2016-05-19 08:21:09 +00:00
Benjamin Kramer 5e6b35f4d1 [include-fixer] Also look up prefixes of queries.
This is used to find nested classes. For a nested name foo::bar::qux we
will first look up foo::bar::qux, then foo::bar, then foo unless we find
a result. This is used to support nested classes which are not part of
the index but can only be used if the header for the parent context is
included.

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

llvm-svn: 269956
2016-05-18 16:42:38 +00:00
Miklos Vajna 5a6d2985d7 clang-rename: handle non-inline ctor definitions when renaming classes
The result of the test was C::D(), not D::D().

Reviewers: cfe-commits, klimek

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

llvm-svn: 269952
2016-05-18 16:12:48 +00:00
Haojian Wu 1bc05a681e [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269928
2016-05-18 14:11:20 +00:00
Eric Liu c7f3b108e2 [clang-include-fixer] Added Vim integration for clang-include-fixer.
Summary: [clang-include-fixer] Added Vim integration for clang-include-fixer.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 269927
2016-05-18 14:10:16 +00:00
Benjamin Kramer 6b5160a369 [include-fixer] Don't insert #includes if a fatal error occurred.
This typically happens when the user didn't setup include paths correctly
and the fixer starts adding garbage includes. Avoid that. Disable the error
limit though, as we might hit that easily with missing includes and still
want to fix those cases.

llvm-svn: 269923
2016-05-18 13:32:38 +00:00
Haojian Wu 4405d5b2cc [clang-tidy] Fix misc-unused-using-decls test failure in windows
buildbot.

llvm-svn: 269918
2016-05-18 13:07:13 +00:00
Haojian Wu 47ea5424d2 [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.
Summary: Ignore warning uninstantiated template function usages.

Reviewers: djasper, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269906
2016-05-18 11:49:34 +00:00
Benjamin Kramer 8b55a2b76c [clang-tidy] Fix a functional change from r269656.
Instead of forming char ranges that patch made us form token ranges,
which behave subtly different. Sadly I'm only seeing this as part of a
larger test case that I haven't fully reduced yet.

llvm-svn: 269896
2016-05-18 09:48:46 +00:00
Benjamin Kramer 2ecd0902c7 [include-fixer] Run tests with -fno-ms-compatibility.
Something behind that flag makes us get fewer typo correction callbacks,
unbreak the tests on windows for now.

llvm-svn: 269894
2016-05-18 09:28:45 +00:00
Haojian Wu ff6d195c2d [include-fixer] Ignore non-scoped enum declaration during search.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269890
2016-05-18 09:04:43 +00:00
NAKAMURA Takumi e1f0ed0a1f findAllSymbols: Prune unused libdeps.
llvm-svn: 269875
2016-05-18 00:53:31 +00:00
NAKAMURA Takumi ea46e8b674 FindAllSymbolsTests doesn't require clangToolingCore.
llvm-svn: 269874
2016-05-18 00:53:27 +00:00
NAKAMURA Takumi 37c64ee4ec include-fixer: They require clangLex.
llvm-svn: 269873
2016-05-18 00:49:16 +00:00
NAKAMURA Takumi 62e8ec5721 IncludeFixerTest.cpp: Add explicit triple for some tests. They are failing for targeting *-win32.
llvm-svn: 269870
2016-05-18 00:20:46 +00:00
Etienne Bergeron e15ef2f609 [clang-tidy] Lift common matchers to utils namespace
Summary:
This patch is lifting matchers used by more than one checkers
to the common namespace.

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269804
2016-05-17 19:36:09 +00:00
Miklos Vajna a7445f1b5e clang-rename: avoid StringRef members in USRLocFindingASTVisitor
Even if this is defined in the .cpp file and only used as part of the
function (so here it's safe), usually storing StringRefs in the class is
dangerous, so don't do so.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269796
2016-05-17 18:17:16 +00:00
Vedant Kumar 5119923cdd [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)
If a use of a macro argument is preceded by the `namespace` keyword, do
not warn that the use should be wrapped in parentheses.

Patch by Mads Ravn!

llvm-svn: 269786
2016-05-17 17:26:02 +00:00
Haojian Wu 2a6d78b820 [find-all-symbols] Add IWYU private pragma support.
Reviewers: djasper, klimek

Subscribers: kimgr, cfe-commits, bkramer, ioeric

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

llvm-svn: 269779
2016-05-17 16:48:49 +00:00
Haojian Wu 39170d70c0 [find-all-symbols] Ignore anonymous enum declarations.
llvm-svn: 269762
2016-05-17 13:38:18 +00:00
Benjamin Kramer af34e06c69 [include-fixer] Make the "extend to the right" hack support typos without nested names in the front.
This handles cases where the initial namespace is unknown.

llvm-svn: 269758
2016-05-17 12:35:18 +00:00
Etienne Bergeron 8d73de9eac [clang-tidy] Cleanups utils files
Summary:
Cleanup some code by using appropriate APIs.
Some coding style cleanups.

There is no behavior changes.

 - Function `IncludeSorter::CreateFixIt` can be replaced by `FixItHint::CreateReplacement`.
 - Function `cleanPath` is a wrapper for `llvm::sys::path::remove_dots`.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269656
2016-05-16 14:34:20 +00:00
Felix Berger 9435f54167 [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
Reviewers: alexfh, sbenza

Subscribers: etienneb, aaron.ballman, cfe-commits

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

llvm-svn: 269581
2016-05-14 22:43:50 +00:00
Eugene Zelenko 804e58d62e [Release notes] Mention Clang-tidy modernize-avoid-bind check.
Fix some problems in its documentation.

llvm-svn: 269517
2016-05-13 23:35:56 +00:00
Etienne Bergeron 8db5174395 [include-fixer] Fix broken dependency shared build
Summary:
The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o: In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o: In function `clang::include_fixer::(anonymous namespace)::runIncludeFixer(llvm::StringRef, std::vector<std::string, std::allocator<std::string> > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
```

Reviewers: bkramer, hokein

Subscribers: cfe-commits

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

llvm-svn: 269441
2016-05-13 17:38:22 +00:00
Haojian Wu 57cdcb07d6 [include-fixer] Use scope contexts information to improve query.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269430
2016-05-13 15:44:16 +00:00
Etienne Bergeron a4bc53afba [clang-rename] Fix broken dependency on shared build.
Summary:
The build is broken due to a missing dependency.

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Which produce this error:
```
tools/clang/tools/extra/clang-rename/CMakeFiles/clangRename.dir/USRLocFinder.cpp.o: In function `clang::RecursiveASTVisitor<clang::rename::(anonymous namespace)::USRLocFindingASTVisitor>::TraverseCXXConstructorDecl(clang::CXXConstructorDecl*)':
USRLocFinder.cpp:(.text._ZN5clang19RecursiveASTVisitorINS_6rename12_GLOBAL__N_123USRLocFindingASTVisitorEE26TraverseCXXConstructorDeclEPNS_18CXXConstructorDeclE+0x170): undefined reference to `clang::Lexer::getSourceText(clang::CharSourceRange, clang::SourceManager const&, clang::LangOptions const&, bool*)'
```

Reviewers: alexfh, yaron.keren

Subscribers: yaron.keren, cfe-commits

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

llvm-svn: 269429
2016-05-13 15:38:54 +00:00
Haojian Wu 631e5f23f9 [include-fixer] Simplify unittest code.
Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269427
2016-05-13 15:17:17 +00:00
Haojian Wu db98f1d9c9 [find-all-symbols] Add EnumDecl type in YAML traits.
llvm-svn: 269422
2016-05-13 14:53:10 +00:00
Benjamin Kramer a3d823336a [include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.

llvm-svn: 269403
2016-05-13 09:27:54 +00:00
Miklos Vajna 1d48e50159 clang-rename: check that the source location we find actually has the old name
This more general check could have prevented the specific problem
"getSourceOrder() == -1" guards.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269402
2016-05-13 09:17:32 +00:00
Haojian Wu 22014750b4 [find-all-symbols] Add enum type support.
Summary:
Also change enums defined in SymbolInfo to scoped enums to avoid
conflicts.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269401
2016-05-13 09:15:37 +00:00
Felix Berger 6d3d746ff5 [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.
Summary: This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269389
2016-05-13 02:47:56 +00:00
Jonathan Coe a30c69c9e4 [clang-tidy] Adds modernize-avoid-bind check
Summary:
This patch adds a check that replaces std::bind with a lambda.

Not yet working for member functions.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269341
2016-05-12 20:06:04 +00:00
Haojian Wu 7a4d510ccb [clang-tidy] Ignore using-declarations defined in marcro in misc-unused-using-decls checks.
Reviewers: djasper

Subscribers: cfe-commits

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

llvm-svn: 269278
2016-05-12 10:00:49 +00:00
Etienne Bergeron c87599f480 [clang-tidy] Improve misc-redundant-expression and decrease false-positive
Summary:
This patch is adding support for conditional expression and overloaded operators.

To decrease false-positive, this patch is adding a list of banned macro names that
has multiple variant with same integer value.

Also fixed support for template instantiation and added an unittest.

Reviewers: alexfh

Subscribers: klimek, Sarcasm, cfe-commits

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

llvm-svn: 269275
2016-05-12 04:32:47 +00:00
Etienne Bergeron 4bf0e62d5a [clang-tidy] Add missing dependency of libtooling to misc module
Summary:
The new API for fixit is in libtooling and the library misc in clang-tidy
didn't had the appropriate dependency.

This commit was breaking some build bots:
http://reviews.llvm.org/D19547

This commit tried (but failed) to fix it:
http://reviews.llvm.org/D20180

To repro, you can make a build with these flags:
```
cmake -DBUILD_SHARED_LIBS=ON
```

Thanks rnk@ for helping figuring out.

Reviewers: alexfh, rnk

Subscribers: cfe-commits

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

llvm-svn: 269240
2016-05-11 21:32:29 +00:00
Eugene Zelenko 1592d76d73 [Clang-tidy] modernize-use-bool-literals: documentation style.
Fix readability-redundant-control-flow warnings in regression test.

llvm-svn: 269229
2016-05-11 20:31:50 +00:00
Etienne Bergeron 8311c446fc [clang-tidy] Refactoring of FixHintUtils
Summary:
Refactor some checkers to use the tooling re-writing API.
see: http://reviews.llvm.org/D19941

Reviewers: klimek, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269210
2016-05-11 17:38:22 +00:00
Etienne Bergeron e646a833ab [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.
Summary:
Arguments can be swapped using fixit when they are not in macros.
This is the same implementation than SwappedArguments. Some code 
got lifted to be reused.

Others checks are not safe to be fixed as they tend to be bugs or errors.
It is better to let the user manually review them.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269208
2016-05-11 17:32:12 +00:00
Benjamin Kramer 79acc976ea [include-fixer] Always ignore SFINAE contexts.
This could lead to spurious includes being added for identifiers that
are supposed to be not available.

llvm-svn: 269195
2016-05-11 15:33:30 +00:00
Benjamin Kramer 3246fba975 [include-fixer] Also output the location where we found an unknown identifier.
For debugging only, makes it a bit easier when there are queries coming
out of headers.

llvm-svn: 269194
2016-05-11 15:33:28 +00:00
Haojian Wu 2d07ed4530 [include-fixer] Add lit-test for relative include path.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269177
2016-05-11 12:30:45 +00:00
Haojian Wu 075ba119b2 [find-all-symbols] Save relative file path for each symbol.
Summary:
The HeaderSearch::suggestPathToFileForDiagnostics used in include-fixer
doesn't work well with absolute file path, it assumes a relative file
path based on header searching path.

So saving relative file path to make include-fixer get the most
appropriate header path.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269173
2016-05-11 11:50:08 +00:00
Jakub Staron f7df72694a [clang-tidy] Adds modernize-use-bool-literals check.
Review link: http://reviews.llvm.org/D18745

llvm-svn: 269171
2016-05-11 11:33:16 +00:00
Benjamin Kramer bfcab592ad [include-fixer] Add basic documentation.
Differential Revision: http://reviews.llvm.org/D20094

llvm-svn: 269167
2016-05-11 09:44:10 +00:00
Haojian Wu 1a352d564f [find-all-symbols] Slim SymbolInfo.
Summary:
SymbolInfo has some optional fields, which is a bad-smell
implementation. For now, we

* remove the optional field since we don't need them (we can probably
  add them back if we actually need them in the future)
* make SymbolInfo to be a class.

By this change, the code is more simplified.

Reviewers: klimek

Subscribers: cfe-commits, ioeric, bkramer

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

llvm-svn: 269162
2016-05-11 08:38:21 +00:00
Miklos Vajna 6477682c98 clang-rename: fix renaming of field with implicit initializers
The last check failed as Cla::Cla() was rewritten to Cla::hector().

Reviewers: cfe-commits, klimek

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

llvm-svn: 269161
2016-05-11 08:08:07 +00:00
NAKAMURA Takumi c92b8e51ae Disable IncludeFixerTests/IncludeFixer.NestedName for now. It doesn't pass for targeting win32. Investigating.
llvm-svn: 269135
2016-05-10 22:46:32 +00:00
Etienne Bergeron de1ec03779 [clang-tidy] Lift parsing of sequence of names functions to utils.
Summary:
Lift some common code used by multiple checkers.

This function is also used by checkers that are coming.
It is quite common for a checker to parse a list of names.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269065
2016-05-10 15:31:15 +00:00
Benjamin Kramer 8fd85a5788 [include-fixer] Default to YAML db, it's much more useful than the fixed dummy db.
llvm-svn: 269043
2016-05-10 11:35:47 +00:00
Benjamin Kramer 8fe4c159b5 [include-fixer] Remove unused includes and accessor.
llvm-svn: 269036
2016-05-10 10:12:00 +00:00
Benjamin Kramer 5471829351 [include-fixer] Emit some terminal output so users can see that the tool is working.
llvm-svn: 269030
2016-05-10 08:36:56 +00:00
Benjamin Kramer ad93500c52 [include-fixer] Work around partial names in both directions.
We already handled the case where we had a nested name specifier where
parts from the beginning don't get a callback, also handle the case
where the end doesn't get a callback. This happens with function calls
in unknown namespaces.

The way we do this for now based on character data is a bit of a hack, we
may need to refine this later or fix clang to produce different callbacks.

llvm-svn: 269029
2016-05-10 08:25:31 +00:00
Benjamin Kramer c3459a5002 [include-fixer] For now, only add the first suggested include.
We used a std::set which made the picked include somewhat random (well,
lexicographically sorted). Make the behavior more consistent by always
picking the first one we found.

llvm-svn: 269028
2016-05-10 08:25:28 +00:00
Haojian Wu bdb54eb457 Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields
Summary:
Fixed a crash in cppcoreguidelines-pro-type-member-init when checking record types with indirect fields pre-C++11.
Fixed handling of indirect fields so they are properly checked and suggested fixes are proposed.

Patch by Michael Miller!

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 269024
2016-05-10 07:42:19 +00:00
Benjamin Kramer b6aed5f441 [include-fixer] Autodetect yaml databases in parent directories.
This looks for find_all_symbols_db.yaml in all parent directories of the
source file (like we do for compile_commands.json) so we don't have to
pass the path manually.

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

llvm-svn: 268920
2016-05-09 14:14:55 +00:00
Haojian Wu 1172668682 [clang-tidy] new google-default-arguments check
Summary:
To check the google style guide rule here:
https://google.github.io/styleguide/cppguide.html#Default_Arguments

Patch by Clement Courbet!

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 268919
2016-05-09 13:43:58 +00:00
Haojian Wu 769eb0d5d5 Support variables and functions types in misc-unused-using-decls.
Summary: Fix PR27429.

Reviewers: djasper

Subscribers: cfe-commits

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

llvm-svn: 268917
2016-05-09 13:37:12 +00:00
Alexander Kornienko 5a520f6cd5 Trying to fix docs.
llvm-svn: 268905
2016-05-09 10:56:57 +00:00
Alexander Kornienko 5d0f2d2135 Fix docs.
llvm-svn: 268899
2016-05-09 10:00:52 +00:00
Miklos Vajna 0f450b6b9a clang-rename tests: move the run lines to the top of the test files
Summary: To be consistent with the other tests.

Reviewers: cfe-commits, klimek

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

llvm-svn: 268897
2016-05-09 08:47:18 +00:00
Miklos Vajna 65f088f528 clang-rename: when renaming a field, rename initializers of that field as well
Summary: The second check failed, the initializer wasn't renamed.

Reviewers: cfe-commits, klimek

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

llvm-svn: 268857
2016-05-07 14:32:59 +00:00
Eugene Zelenko 07fa815c65 [Documentation] List Clang-tidy checks alphabetically.
llvm-svn: 268659
2016-05-05 18:25:53 +00:00
Alexander Kornienko 1ccc219125 [clang-tidy] Improve -warnings-as-errors tests.
llvm-svn: 268579
2016-05-05 00:09:29 +00:00
Alexander Kornienko dbefbdb6d1 [clang-tidy] Apply NOLINT filtering to Clang warnings.
llvm-svn: 268555
2016-05-04 21:18:31 +00:00
Gabor Horvath 30e962a158 [clang-tidy] Remove STL dependency from a test.
llvm-svn: 268494
2016-05-04 12:17:55 +00:00
Gabor Horvath 112d1e80c0 [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature
Summary: Finds return statements in assign operator bodies where the return value is different from '*this'. Only assignment operators with correct return value Class& are checked.

Reviewers: aaron.ballman, alexfh, sbenza

Subscribers: o.gyorgy, baloghadamsoftware, LegalizeAdulthood, aaron.ballman, Eugene.Zelenko, xazax.hun, cfe-commits

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

llvm-svn: 268492
2016-05-04 12:02:22 +00:00
Manuel Klimek 13e2c1a709 When renaming a class, ename pointers to that class as well.
Patch by Miklos Vajna.

llvm-svn: 268484
2016-05-04 09:45:44 +00:00
Eric Liu 692aca6980 Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.
Summary: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

Reviewers: hokein, djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 268480
2016-05-04 08:22:35 +00:00
Felix Berger 99a0dddb3a [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.
Reviewers: alexfh

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 268461
2016-05-03 23:07:44 +00:00
Samuel Benzaquen 4e05b82cc4 [clang-tidy] Speedup misc-static-assert.
Summary:
Speedup the misc-static-assert check by not use `stmt()` as the toplevel matcher.
The framework runs a filter on the matchers before trying them on each node and
uses the toplevel type for this.
Using `stmt()` as the toplevel causes the matcher to be run on every `Stmt` node,
even if the node doesn't match the desired types.

This change speeds up clang-tidy by ~5% in a benchmark.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268430
2016-05-03 20:11:09 +00:00
Haojian Wu 2e1ebca2c4 Fix cppcoreguidelines-pro-type-member-init failure test on Windows.
llvm-svn: 268374
2016-05-03 11:19:46 +00:00
Haojian Wu a315dcb3da [include-fixer] Abstract includeFixerMain function.
llvm-svn: 268371
2016-05-03 08:38:35 +00:00
Haojian Wu b5cac80c77 Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base
Summary: Fix a crash when a record type initializes itself in its own base class initializer list.

Patch by Michael Miller!

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: cfe-commits

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

llvm-svn: 268369
2016-05-03 08:11:47 +00:00
Etienne Bergeron 2a4c00f243 [clang-tidy] Cleanup namespace in utils folder.
Summary:
This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268356
2016-05-03 02:54:05 +00:00
Felix Berger b6947a5847 [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer.
Reviewers: alexfh, JVApen, aaron.ballman

Subscribers: flx, aaron.ballman, cfe-commits

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

llvm-svn: 268352
2016-05-03 01:41:19 +00:00
Eugene Zelenko a19859d589 [Clang-tidy] Fix Clang-tidy modernize-use-override and some Include What You Use warnings in modernize/MakeSmartPtrCheck.h.
llvm-svn: 268349
2016-05-03 01:13:27 +00:00
Etienne Bergeron 456177b98f [clang-tidy] Cleaning namespaces to be more consistant across checkers.
Summary:
The goal of the patch is to bring checkers in their appropriate namespace.
This path doesn't change any behavior.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268264
2016-05-02 18:00:29 +00:00
Eugene Zelenko a54a212d9d [include-fixer] Fix Clang-tidy modernize-use-override and some Include What You Use warnings.
Differential revision: http://reviews.llvm.org/D19755

llvm-svn: 268262
2016-05-02 17:49:00 +00:00
Piotr Padlewski ce18ade406 [clang-tidy] Add modernize-make-shared check
Because modernize-make-shared do almost the same job as
modernize-make-unique, I refactored common code to MakeSmartPtrCheck.

http://reviews.llvm.org/D19183

llvm-svn: 268253
2016-05-02 16:56:39 +00:00
Eugene Zelenko 5b407543c0 [Release Notes] Mention Clang-tidy cert-err34-c check.
Fix order and style of Boost related notes.

llvm-svn: 268140
2016-04-30 00:11:10 +00:00
Aaron Ballman d744e63d90 Add a clang-tidy check that flags string-to-number conversion functions that have insufficient error checking, suggesting a better alternative.
This check corresponds to: https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number

llvm-svn: 268100
2016-04-29 20:56:48 +00:00
Piotr Padlewski 5625f65667 Add boost-use-to-string
http://reviews.llvm.org/D18136

llvm-svn: 268079
2016-04-29 17:58:29 +00:00
Piotr Padlewski 74ca1cc7d0 small reformat to test access
llvm-svn: 268076
2016-04-29 17:45:20 +00:00
Benjamin Kramer 683e592ff3 [find-all-symbols] Parallelize the merge step.
There is still more parallelism to get here because we synchonize on the
actual uniquing but just doing YAML parsing in parallel already gives a
significant speedup.

Merging all symbols in LLVM+clang+compiler-rt+lld+libc++, 48 cores.
before: 201.55s user 1.47s system 99% cpu 3:23.04 total
after:  276.99s user 7.63s system 838% cpu 33.947 total

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

llvm-svn: 268037
2016-04-29 12:46:27 +00:00
Benjamin Kramer 4f3c985edd Make run-find-all-symbols executable.
llvm-svn: 268022
2016-04-29 10:33:11 +00:00
Benjamin Kramer 027163e98b [find-all-symbols] Fix racy yaml file writing.
If multiple find-all-symbols processes access the temporary directory
simultaneously with two files with the same name they would collide and
create a broken yaml file. Fix this by using the safe createUniqueFile
API from LLVM instead.

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

llvm-svn: 268021
2016-04-29 10:16:28 +00:00
Haojian Wu e5966e7309 [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 268019
2016-04-29 09:45:09 +00:00
Haojian Wu d8c12badad [include-fixer] Add Yaml database integration.
Reviewers: bkramer

Subscribers: cfe-commits, klimek, djasper

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

llvm-svn: 268017
2016-04-29 09:23:38 +00:00
Alexander Kornienko fabdbe4732 [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables
Summary:
Variables with static storage duration are zero-initialized per
[stmt.dcl]p4 and [basic.start.init]p2.

Reviewers: sbenza, aaron.ballman

Subscribers: michael_miller, flx, cfe-commits

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

llvm-svn: 267933
2016-04-28 20:20:01 +00:00
Benjamin Kramer 3a45fab72b [include-fixer] Add an option to minimize include paths.
This will always pick the shortest possible path based on -I options. Based
on the #include suggestion code for modules.

llvm-svn: 267868
2016-04-28 11:21:29 +00:00
Manuel Klimek bc5f581d47 Add missing newline in clang-rename output.
Patch by Miklos Vajna.

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

llvm-svn: 267855
2016-04-28 06:46:44 +00:00
NAKAMURA Takumi d016c3e3a0 FindAllSymbolsTest.CTypedefTest: Tweak for LLP64 like x86_64-win32.
In file included from symbol.cc:1:
  symbols.h:2:24: error: typedef redefinition with different types ('unsigned int'
        vs 'unsigned long long')
        typedef unsigned size_t;
                         ^

llvm-svn: 267841
2016-04-28 02:15:16 +00:00
Stephen Hines 15643352eb Fix include path in ClangTidy.cpp.
Summary:
https://llvm.org/bugs/show_bug.cgi?id=27355
To compile with other binary output directory structures in build systems like Android.

Reviewers: srhines, alexfh

Subscribers: tberghammer, danalbert, cfe-commits

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

llvm-svn: 267835
2016-04-28 01:42:12 +00:00
NAKAMURA Takumi f46c273977 clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp: Appease ms targets with -fno-delayed-template-parsing.
llvm-svn: 267828
2016-04-28 00:39:48 +00:00
Simon Pilgrim b9f255878e Wdocumentation fix
llvm-svn: 267786
2016-04-27 20:43:32 +00:00
David Blaikie 5593ce5633 Fix a bunch of sign-compare warnings
llvm-svn: 267754
2016-04-27 18:47:45 +00:00
Benjamin Kramer 5567ce0f98 [find-all-symbols] Also update unittest dependencies.
llvm-svn: 267739
2016-04-27 16:56:29 +00:00
Benjamin Kramer bac3a96389 [find-all-symbols] Clean up dependencies, fixing cmake shared build.
llvm-svn: 267738
2016-04-27 16:50:17 +00:00
Haojian Wu 8eb70bc625 Fix explain-check failure test on Windows.
llvm-svn: 267736
2016-04-27 16:39:42 +00:00
Haojian Wu 5b759f82fa Don't search compilation database in explain-check, fixing buildbot test
failure.

llvm-svn: 267731
2016-04-27 16:09:34 +00:00
Benjamin Kramer cf4c6d860a Add missing dependency.
llvm-svn: 267721
2016-04-27 14:32:36 +00:00
Haojian Wu f875acbd77 [include-fixer] Add a find-all-symbols tool for include-fixer.
Summary:
The find-all-symbols tool generates a yaml symbol database for
include-fixer.

The symbol matcher is originally written by Xiaoyi Liu.

Reviewers: bkramer, djasper

Subscribers: cfe-commits, klimek, ioeric

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

llvm-svn: 267719
2016-04-27 14:27:05 +00:00
Benjamin Kramer f412e9029d Clean up the include fixer 'driver' a bit and make the database configurable.
Also add a test for it. The library is covered by unit tests, the driver
was not.

llvm-svn: 267718
2016-04-27 14:24:32 +00:00
Haojian Wu 68d2b881d2 Remove explain-config testcase that detect hard-coded check.
Remove it for now, we need to better way to figure out how to test it.

llvm-svn: 267711
2016-04-27 13:23:39 +00:00
Haojian Wu 20d4c20bca Fix a crash in cppcoreguidelines-pro-type-member-init when checking a type with a template parameter as a base class.
Summary: Fixed a crash in cppcoreguidelines-pro-type-member-init when encountering a type that uses one of its template parameters as a base when compiling for C++98.

Patch by Michael Miller!

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 267700
2016-04-27 12:17:04 +00:00
Alexander Kornienko 493db093be clang-tidy -list-checks should exit with non-zero code when no checks are enabled.
llvm-svn: 267697
2016-04-27 11:45:14 +00:00
Haojian Wu cd32384539 Don't search compilation database in explain-check test.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267687
2016-04-27 10:22:31 +00:00
Haojian Wu 12e6b8f929 [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267683
2016-04-27 09:15:01 +00:00
Alexander Kornienko 900cadd3ad [clang-tidy] Now adding correct misc-move-const-arg documentation ;]
+ brushed the code a bit and renamed the test file to match the check name

llvm-svn: 267592
2016-04-26 19:33:49 +00:00
Alexander Kornienko 1af58fc1e5 [clang-tidy] Added misc-move-const-arg docs.
llvm-svn: 267587
2016-04-26 18:48:59 +00:00
Eugene Zelenko ca943b3929 [Release notes] Mention Clang-tidy misc-fold-init-type check.
Highlighting consistency in Clang-tidy misc-fold-init-type check documentation.

llvm-svn: 267576
2016-04-26 17:54:00 +00:00
Etienne Bergeron bda187decd [clang-tidy] New checker for redundant expressions.
Summary:
This checker finds redundant expression on both side of a binary operator.

The current implementation provide a function to check whether expressions
are equivalent. This implementation is able to recognize the common
subset encounter in C++ program. Side-effects like "x++" are not considered
to be equivalent.

There are many False Positives related to macros and to floating point
computations (detecting NaN). The checker is ignoring these cases.

Example:
```
    if( !dst || dst->depth != desired_depth ||
        dst->nChannels != desired_num_channels ||
        dst_size.width != src_size.width ||
        dst_size.height != dst_size.height )    <<--- bug
    {
```

Reviewers: alexfh

Subscribers: danielmarjamaki, fahlgren, jordan_rose, zaks.anna, Eugene.Zelenko, cfe-commits

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

llvm-svn: 267574
2016-04-26 17:30:30 +00:00
Etienne Bergeron 1b94f6504b [clang-tidy] Enhance misc-suspicious-string-compare to move down false-positives.
Summary:
The checker was noisy when running over llvm code base.
This patch is impriving the way string-compare functions are matched.

1) By default, do not report !strcmp(...) unless it's activate by the user,
2) Only match suspicious expression over a subset of expression (binary operator),
3) Added matching of macro wrapper used with clang on linux.

See bug: 27465.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267570
2016-04-26 16:53:21 +00:00
Alexander Kornienko 6e2f32c561 A clang-tidy check for std:accumulate.
Summary:
For folds (e.g. std::accumulate), check matches between the provided init value and the range's value_type. A typical error is "std::accumulate(begin, end, 0);", where begin and end have float value_type. See the documentation for more examples.

For now we check std::accumulate, std::reduce and std::inner_product.

Reviewers: hokein, alexfh

Subscribers: Prazek, aaron.ballman, cfe-commits, courbet

Patch by Clément Courbet!

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

llvm-svn: 267542
2016-04-26 10:05:45 +00:00
NAKAMURA Takumi 66b0a87ae8 clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp: Use raw_string_ostream::str() to flush the buffer explicitly.
llvm-svn: 267290
2016-04-23 14:54:28 +00:00
Alexander Kornienko 5142c0d7fa [clang-tidy] Fix misc-macro-repeated-side-effects false positive with stringified arguments
llvm-svn: 267254
2016-04-23 00:00:08 +00:00
Eugene Zelenko 6cac934051 [Clang-tidy] Fix Clang warning in misc/StringConstructorCheck.h.
Using LLVM_ENABLE_WARNINGS=ON is good idea.

llvm-svn: 267228
2016-04-22 21:33:33 +00:00
Haojian Wu bee3c88ec6 [clang-tidy] fix link in Release Notes
Summary: This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=27426

Patch by Kirill Bobyrev!

Reviewers: alexfh, LegalizeAdulthood, hokein

Subscribers: cfe-commits

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

llvm-svn: 267155
2016-04-22 14:43:39 +00:00
NAKAMURA Takumi 70191d628f clangTidyReadabilityModule: Add clangTidyUtils in libdeps, corresponding to r267003.
llvm-svn: 267087
2016-04-22 00:33:39 +00:00
Etienne Bergeron 7e02656004 [clang-tidy] Fix broken build bot.
Summary:
There is a build bot that doesn't support 'constexpr'.

```
FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\misc -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include -Itools\clang\include -Iinclude -ID:\buildslave\clang-x64-ninja-win7\llvm\include    -UNDEBUG  /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS /Fotools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\SuspiciousStringCompareCheck.cpp.obj /Fdtools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\ /FS -c D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25) : error C2144: syntax error : 'char' should be preceded by ';'
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
ninja: build stopped: subcommand failed.
program finished with exit code 1
```

Reviewers: alexfh, sbenza

Subscribers: cfe-commits

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

llvm-svn: 267027
2016-04-21 18:15:35 +00:00
Eugene Zelenko 656eb13fe0 [Release Notes] Mention Clang-tidy misc-string-constructor and misc-suspicious-string-compare checks.
Fix excessive line in misc-string-constructor documentation.

llvm-svn: 267026
2016-04-21 18:13:09 +00:00
Etienne Bergeron 1dbd582387 [clang-tidy] New checker to detect suspicious string constructor.
Summary:
Checker to validate string constructor parameters.

A common mistake is to swap parameter for the fill-constructor.
```
  std::string str('x', 4);
  std::string str('4', x);
```

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267011
2016-04-21 17:28:08 +00:00
Etienne Bergeron bae829ede5 [clang-tidy] Add new checker for comparison with runtime string functions.
Summary:
This checker is validating suspicious usage of string compare functions.

Example:
```
  if (strcmp(...))       // Implicitly compare to zero
  if (!strcmp(...))      // Won't warn
  if (strcmp(...) != 0)  // Won't warn
```

This patch was checked over large amount of code.
There is three checks:
  [*] Implicit comparator to zero (coding-style, many warnings found),
  [*] Suspicious implicit cast to non-integral (bugs!?, almost none found),
  [*] Comparison to suspicious constant (bugs!?, found two cases),

Example:
[[https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c |
https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c]]

```
      else if(strcmp(id, "select") == 0)
      {
         array->array[i].key1 = 25;
      }
      else if(strcmp(id, "sk") == 28)      // BUG!?
      {
         array->array[i].key1 = 20;
      }
```

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

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

llvm-svn: 267009
2016-04-21 17:19:36 +00:00
Etienne Bergeron 9d26599078 [clang-tidy] Cleanup some ast-matchers and lift some to utils.
Summary:
Little cleanup to lift-out and to remove some frequently used
ast-matchers.

Some of theses matchers are candidates to be lifted to ASTMatchers.h.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267003
2016-04-21 16:57:56 +00:00
Alexander Kornienko bfb43b7298 [Clang-tidy] Fix for crash in modernize-raw-string-literal check
Summary:
Clang-tidy modernize-raw-string-literal check crashes on run-time assert while it is evaluating compiler predefined identifiers such as
- __FUNCTION__
- __func__
- __PRETTY_FUNCTION__

Check is asserting because it cannot find opening quote for such string literal. It occurs only on debug build config.
I think that it would be good to prune such cases by crossing off predefined expressions - there is no need to evaluate such matches.

Reviewers: LegalizeAdulthood, alexfh

Subscribers: cfe-commits

Patch by Marek Jenda!

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

llvm-svn: 266992
2016-04-21 14:39:12 +00:00
Haojian Wu 9cba1b52ef Fix cast compiler warning message in include-fixer.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 266970
2016-04-21 09:16:32 +00:00
NAKAMURA Takumi f2c717be82 IncludeFixerTest.cpp: Tweak not to assume clang-tools-extra were onto clang/tools/extra.
llvm-svn: 266874
2016-04-20 14:14:16 +00:00
Benjamin Kramer 6b23626192 [include-fixer] Add a prototype for a new include fixing tool.
Summary:
The goal of this tool is fairly simple, look up unknown identifiers in a
global database and add the corresponding #include line. It accomplishes
this by hooking into Sema as an ExternalSemaSource and responding to typo
correction callbacks. This means we can see the unknown identifier before
it's being munged by error recovery.

This doesn't work perfectly yet as some typo corrections don't emit
callbacks (delayed typos), but I think this is fixable. We also handle
only one include at a time as this is meant to be run directly from
the editing environment eventually. Adding multiple includes at the same
time is tricky because of error recovery.

This version only has a a dummy database, so all you can do is fixing
missing includes of <string>, but the indexer to build a database will
follow soon.

Reviewers: djasper

Subscribers: ioeric, hokein, cfe-commits

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

llvm-svn: 266870
2016-04-20 12:43:43 +00:00