Add matcher for AccessSpecDecls.

Also, add matchers isPrivate(), isProtected() and isPublic(), that
restrict the matching of such AccessSpecDecls and all other Decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176017 91177308-0d34-0410-b5e6-96231b3b80d8
Update generated documentation after recent matcher addition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176018 91177308-0d34-0410-b5e6-96231b3b80d8
Support in hasDeclaration for types with getDecl()

Re-introducing r175532. The has_getDecl metafunction didn't compile with Visual
Studio. This revision approaches has_getDecl from a different angle that isn't
a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176019 91177308-0d34-0410-b5e6-96231b3b80d8
Reverting r176019. Corrupt patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176021 91177308-0d34-0410-b5e6-96231b3b80d8
Support in hasDeclaration for types with getDecl()

Re-introducing r175532. The has_getDecl metafunction didn't compile with
Visual Studio. This revision uses approaches has_getDecl from a
different angle that isn't a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176024 91177308-0d34-0410-b5e6-96231b3b80d8
Adding hasDeclaration overload for TemplateSpecializationType

TemplateSpecializationType doesn't quite have getDecl(). Need to go
through TemplateName to get a TemplateDecl.

Added test cases for the hasDeclaration() overload for
TemplateSpecializationType. Also introduced the type matcher
templateSpecializationType() used by the new hasDeclaration() test case.

Updated LibASTMatchersReference.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176025 91177308-0d34-0410-b5e6-96231b3b80d8
Re-add hack that caused regression.

This fixes llvm.org/PR15350.

Before:
Constructor(int Parameter = 0)
    : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
                aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

After:
Constructor(int Parameter = 0)
    : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
      aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

I think the correct solution is to put the VariablePos into
ParenState, not LineState. Added FIXME.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176032 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Base regions may be invalid when layered on symbolic regions.

While RegionStore checks to make sure casts on TypedValueRegions are valid,
it does not do the same for SymbolicRegions, which do not have perfect type
info anyway. Additionally, MemRegion::getAsOffset does not take a
ProgramState, so it can't use dynamic type info to determine a better type
for the regions. (This could also be dangerous if the type of a super-region
changes!)

Account for this by checking that a base object region is valid on top of a
symbolic region, and falling back to "symbolic offset" mode if not.

Fixes PR15345.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176034 91177308-0d34-0410-b5e6-96231b3b80d8
Fix empty declaration printing.

Don't print the semicolon when visiting an empty declaration because the semicolon
will be printed as a terminator later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176035 91177308-0d34-0410-b5e6-96231b3b80d8
Add a front-end test case for r176036.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176038 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Handle reference parameters with default values.

r175026 added support for default values, but didn't take reference
parameters into account, which expect the default argument to be an
lvalue. Use createTemporaryRegionIfNeeded if we can evaluate the default
expr as an rvalue but the expected result is an lvalue.

Fixes the most recent report of PR12915. The original report predates
default argument support, so that can't be it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176042 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Address Jordan's code review of r175857.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176043 91177308-0d34-0410-b5e6-96231b3b80d8
Revert "Add more attributes from the command line to functions."

This reverts commit 176009.

The commit is a likely cause of several buildbot failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176044 91177308-0d34-0410-b5e6-96231b3b80d8
Various additions to ASTMatcher library:
    
New type matchers:
* recordType
* elaboratedType

New narrowing matchers:
* hasQualifier
* namesType
* hasDeclContext

Added tests and updated LibASTMatchersReference.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176047 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Recover all PreStmtPurgeDeadSymbols nodes with a single successor or predecessor.

These nodes are never consulted by any analyzer client code, so they are
used only for machinery for removing dead bindings.  Once successor nodes
are generated they can be safely removed.

This greatly reduces the amount of nodes that are generated in some case,
lowering the memory regression when analyzing Sema.cpp introduced by
r176010 from 14% to 2%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176050 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Restrict ObjC type inference to methods that have related result type.

This addresses a case when we inline a wrong method due to incorrect
dynamic type inference. Specifically, when user code contains a method from init
family, which creates an instance of another class.

Use hasRelatedResultType() to find out if our inference rules should be triggered.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176054 91177308-0d34-0410-b5e6-96231b3b80d8
[ubsan] Emit single check for left shift.

Avoids warning twice on same shift.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176056 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] StackAddrEscapeChecker: strip qualifiers from temporary types.

With the new support for trivial copy constructors, we are not always
consistent about whether a CXXTempObjectRegion gets reused or created
from scratch, which affects whether qualifiers are preserved. However,
we probably don't care anyway.

This also switches to using the current PrintingPolicy for the type,
which means C++ types don't get a spurious 'struct' prefix anymore.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176068 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Don't look through casts when creating pointer temporaries.

Normally, we need to look through derived-to-base casts when creating
temporary object regions (added in r175854). However, if the temporary
is a pointer (rather than a struct/class instance), we need to /preserve/
the base casts that have been applied.

This also ensures that we really do create a new temporary region when
we need to: MaterializeTemporaryExpr and lvalue CXXDefaultArgExprs.

Fixes PR15342, although the test case doesn't include the crash because
I couldn't isolate it.

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