[clang-tidy] Add a checker that warns on const string & members.

Summary:
Those are considered unsafe and should be replaced with simple pointers or
full copies. It recognizes both std::string and ::string.

Reviewers: alexfh, djasper

Subscribers: cfe-commits

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

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213133 91177308-0d34-0410-b5e6-96231b3b80d8
Added documentation on how clang diagnostics are reported by clang-tidy.


git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213147 91177308-0d34-0410-b5e6-96231b3b80d8
Avoid adding redundant parens.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, sbenza

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

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213149 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Add namespaces checkers.

This change contains of two checkers that warn about
1. anonymous namespaces in header files.
2. 'using namespace' directives everywhere.

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

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213153 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Add a checker for zero-length memset.

If there's memset(x, y, 0) in the code it's most likely a mistake. The
checker suggests a fix-it to swap 'y' and '0'.

I think this has the potential to be promoted into a general clang warning
after some testing in clang-tidy.

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

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213155 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Also emit a warning for memset(x, 0, 0)

It doesn't make sense to suggest swapping the arguments here but it's
still useless code

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213156 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] As a simple heuristic don't emit a swap fixit that would create
negative-sized memsets.

memset(x, -1, 0) is still useless but swapping makes no sense here. Just emit
a warning.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213157 91177308-0d34-0410-b5e6-96231b3b80d8
Track clang r213171

The clang rewriter is now a core facility.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213172 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Provide links to the google style guide for checks derived from it.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213233 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] MemsetZeroLenghtChecker: Don't crash trying to evaluate dependent values.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213238 91177308-0d34-0410-b5e6-96231b3b80d8
Make the diagnostic message more complete to check the check name.


git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213245 91177308-0d34-0410-b5e6-96231b3b80d8
unique_ptr-ify ownership of ASTConsumers

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213308 91177308-0d34-0410-b5e6-96231b3b80d8
Revert "unique_ptr-ify ownership of ASTConsumers"

This reverts commit r213308.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213324 91177308-0d34-0410-b5e6-96231b3b80d8
clang-tidy: [misc-use-override] Slightly tweak the wording of warning.

'final' should really be used with care.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213501 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Fix a false positive in the make_pair checker if an argument has a explicit template argument.

This required a rather ugly workaround for a problem in ASTMatchers where
callee() is only overloaded for Stmt and Decl but not for Expr.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213509 91177308-0d34-0410-b5e6-96231b3b80d8
[clang-tidy] Add a check for RAII temporaries.

Summary:
This tries to find code similar that immediately destroys
an object that looks like it's trying to follow RAII.
  {
    scoped_lock(&global_mutex);
    critical_section();
  }

This checker will have false positives if someone uses this pattern
to legitimately invoke a destructor immediately (or the statement is
at the end of a scope anyway). To reduce the number we ignore this
pattern in macros (this is heavily used by gtest) and ignore objects
with no user-defined destructor.

Reviewers: alexfh, djasper

Subscribers: cfe-commits

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

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213647 91177308-0d34-0410-b5e6-96231b3b80d8
Revert r213647; the added test triggers an assertion.


git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213722 91177308-0d34-0410-b5e6-96231b3b80d8
Reapply r213647 with a fix.

ASTMatchers currently have problems mixing bound TypeLoc nodes with Decl/Stmt
nodes. That should be fixed soon but for this checker there we only need the
TypeLoc to generate a fixit so postpone the potentially heavyweight AST walking
until after we know that we're going to emit a warning.

This is covered by existing test cases.

Original message:
[clang-tidy] Add a check for RAII temporaries.

This tries to find code similar that immediately destroys
an object that looks like it's trying to follow RAII.
  {
    scoped_lock(&global_mutex);
    critical_section();
  }

This checker will have false positives if someone uses this pattern
to legitimately invoke a destructor immediately (or the statement is
at the end of a scope anyway). To reduce the number we ignore this
pattern in macros (this is heavily used by gtest) and ignore objects
with no user-defined destructor.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213738 91177308-0d34-0410-b5e6-96231b3b80d8
check_clang_tidy_fix.sh: Fail immediately if clang-tidy crashes.

Otherwise we'll get confusing messages from FileCheck instead of seeing the real issue.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213739 91177308-0d34-0410-b5e6-96231b3b80d8
Add the fix that should've accompanied r213738.

git-svn-id: http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@213740 91177308-0d34-0410-b5e6-96231b3b80d8