AST matcher tutorial (Part I)

This an AST matcher tutorial based on Sam Panzer's document
(https://docs.google.com/a/google.com/document/d/1oTkVLhCdRJUEH1_LDaQdXqe8-aOqT5GLDL9e4MhoFF8/edit).

Checking in now although some parts might be a bit rough so others can
help improving it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169632 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Optimization heuristic: do not reanalyze every ObjC method as
top level.

This heuristic is already turned on for non-ObjC methods
(inlining-mode=noredundancy). If a method has been previously analyzed,
while being inlined inside of another method, do not reanalyze it as top
level.

This commit applies it to ObjCMethods as well. The main caveat here is
that to catch the retain release errors, we are still going to reanalyze
all the ObjC methods but without inlining turned on.

Gives 21% performance increase on one heavy ObjC benchmark, which
suffered large performance regressions due to ObjC inlining.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169639 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Rename the option help to reflect better what it does.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169640 91177308-0d34-0410-b5e6-96231b3b80d8
[libclang] Declarations inside anonymous namespaces have internal linkage so
their USR should contain a location.

This uniques them from other declarations with the same name but in different translation units.
rdar://10546541

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169647 91177308-0d34-0410-b5e6-96231b3b80d8
Appease -Wnon-virtual-dtor

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169648 91177308-0d34-0410-b5e6-96231b3b80d8
Fix analysis based warnings so that all warnings are emitted when compiling
with -Werror.  Previously, compiling with -Werror would emit only the first
warning in a compilation unit, because clang assumes that once an error occurs,
further analysis is unlikely to return valid results.  However, warnings that
have been upgraded to errors should not be treated as "errors" in this sense.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169649 91177308-0d34-0410-b5e6-96231b3b80d8
s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169652 91177308-0d34-0410-b5e6-96231b3b80d8
Currently when AST record layouts are dumped with -fdump-record-layouts, the
following:

sizeof=132, dsize=132, align=4
nvsize=132, nvalign=4

Is not indented, so when classes are nested there is no way to know to
which class it belongs.

Fix this problem by indenting the size summary properly for each class.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169654 91177308-0d34-0410-b5e6-96231b3b80d8
Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169662 91177308-0d34-0410-b5e6-96231b3b80d8
Add a FIXME.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169664 91177308-0d34-0410-b5e6-96231b3b80d8
[Preprocessor] Enhance Ifdef/Ifndef/Defined preprocessor callbacks to also pass
a MacroInfo object if the identifier was a macro name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169665 91177308-0d34-0410-b5e6-96231b3b80d8
[libclang] Resolve a cursor that points to a macro name inside a #ifdef/#ifndef
directive as a macro expansion.

This is more of a "macro reference" than a macro expansion but it's close enough
for libclang's purposes. If it causes issues we can revisit and introduce a new
kind of cursor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169666 91177308-0d34-0410-b5e6-96231b3b80d8
Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.

This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.

This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169667 91177308-0d34-0410-b5e6-96231b3b80d8
Thread-safety analysis: check member access on guarded non-primitive types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169669 91177308-0d34-0410-b5e6-96231b3b80d8
Remove some remnants of the assumption that there is at most one of each
flavour of special member.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169670 91177308-0d34-0410-b5e6-96231b3b80d8
Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169673 91177308-0d34-0410-b5e6-96231b3b80d8
long double should be 64 bits on FreeBSD/MIPS64.  It possibly should be on
Linux too, as I think we inherited it from there.  The ABI spec says 128-bit,
although I think SGI's compiler on IRIX may be the only thing ever to support
this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169674 91177308-0d34-0410-b5e6-96231b3b80d8
Escape % in the TextDiagnosticBuffer so they aren't interpreted twice when fed into the diagnostic formatting machinery again.

Fixes PR14543.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169677 91177308-0d34-0410-b5e6-96231b3b80d8
PR14549. Don't assert if we see an incomplete decltype specifier at the end of the file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169688 91177308-0d34-0410-b5e6-96231b3b80d8
PR14550: If a system header contains a bogus constexpr function definition,
don't mark the function as invalid, since we suppress the error.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169689 91177308-0d34-0410-b5e6-96231b3b80d8