In -Wunneeded-internal-declaration, suppress the warning for variables which
might have been used in constant expressions, rather than suppressing it for
variables which are const. The important thing here is that such variables
can have their values used without actually being marked as 'used'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166896 91177308-0d34-0410-b5e6-96231b3b80d8
When determining whether to try evaluating the initializer of a variable, check
whether the initializer is value-dependent rather than whether we are in a
dependent context. This allows us to detect some errors sooner, and fixes a
crash-on-invalid if a dependent type leaks out to a non-dependent context in
error recovery.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166898 91177308-0d34-0410-b5e6-96231b3b80d8
Revert functional part of r166896 and just suppress -Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166899 91177308-0d34-0410-b5e6-96231b3b80d8
improve highlighting of invalid string encodings

limit highlight to exactly the bad encoding, and highlight every
bad encoding in a string.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166900 91177308-0d34-0410-b5e6-96231b3b80d8
Add missing emacs major mode marker.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166912 91177308-0d34-0410-b5e6-96231b3b80d8
Fix name of this file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166913 91177308-0d34-0410-b5e6-96231b3b80d8
Add missing emacs major mode marker.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166914 91177308-0d34-0410-b5e6-96231b3b80d8
Remove spurious mode marker from .cpp file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166915 91177308-0d34-0410-b5e6-96231b3b80d8
Implement has(), hasDescendant(), forEach() and forEachDescendant() for
Types, QualTypes and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D83

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166917 91177308-0d34-0410-b5e6-96231b3b80d8
Fix ASTMatchersTests to not create an overloaded-virtual warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166921 91177308-0d34-0410-b5e6-96231b3b80d8
Handle '*' and '#' asm constraint modifiers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166924 91177308-0d34-0410-b5e6-96231b3b80d8
This patch adds alignment information for long double to the 64-bit PowerPC
ELF subtarget.

The existing description string is moved from PPC64TargetInfo to its
DarwinTargetInfo subclass, to avoid any changes to the Darwin ABI.
PPC64TargetInfo now has two possible description strings: one for FreeBSD,
which requires 8-byte alignment, and a default string that requires
16-byte alignment.

I've added a test for PPC64 Linux to verify the 16-byte alignment.  If
somebody wants to add a separate test for FreeBSD, that would be great.

Note that there is a companion patch to update the alignment information
in LLVM, which I am committing now as well.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166927 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Use the CallEnter node to get a value for tracked null arguments.

Additionally, don't collect PostStore nodes -- they are often used in
path diagnostics.

Previously, we tried to track null arguments in the same way as any other
null values, but in many cases the necessary nodes had already been
collected (a memory optimization in ExplodedGraph). Now, we fall back to
using the value of the argument at the time of the call, which may not
always match the actual contents of the region, but often will.

This is a precursor to improving our suppression heuristic.
<rdar://problem/12350829>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166940 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] New option to not suppress null return paths if an argument is null.

Our one basic suppression heuristic is to assume that functions do not
usually return NULL. However, when one of the arguments is NULL it is
suddenly much more likely that NULL is a valid return value. In this case,
we don't suppress the report here, but we do attach /another/ visitor to
go find out if this NULL argument also comes from an inlined function's
error path.

This new behavior, controlled by the 'avoid-suppressing-null-argument-paths'
analyzer-config option, is turned off by default. Turning it on produced
two false positives and no new true positives when running over LLVM/Clang.

This is one of the possible refinements to our suppression heuristics.
<rdar://problem/12350829>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166941 91177308-0d34-0410-b5e6-96231b3b80d8
-Warc-repeated-use-of-weak: allow single reads in loops from local variables.

Previously, the warning would erroneously fire on this:

for (Test *a in someArray)
  use(a.weakProp);

...because it looks like the same property is being accessed over and over.
However, clearly this is not the case. We now ignore loops like this for
local variables, but continue to warn if the base object is a parameter,
global variable, or instance variable, on the assumption that these are
not repeatedly usually assigned to within loops.

Additionally, do-while loops where the condition is 'false' are not really
loops at all; usually they're just used for semicolon-swallowing macros or
using "break" like "goto".

<rdar://problem/12578785&12578849>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166942 91177308-0d34-0410-b5e6-96231b3b80d8
Make forcesizeopt attribute available to the end user

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166946 91177308-0d34-0410-b5e6-96231b3b80d8
Partially roll back r166898; it exposed a bug in the standard.

The problem is as follows: C++11 has contexts which are not
potentially-evaluated, and yet in which we are required or encouraged to
perform constant evaluation. In such contexts, we are not permitted to
implicitly define special member functions for literal types, therefore
we cannot evalaute those constant expressions.

Punt on this in one more context for now by skipping checking constexpr
variable initializers if they occur in dependent contexts.


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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166957 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Add checker helpers to CheckerContext.

- Adding Immutable Map to GDM and getIdentifierInfo helper method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166975 91177308-0d34-0410-b5e6-96231b3b80d8
[analyzer] Add SimpleStreamChecker.

This is an example checker for catching fopen fclose API misuses.

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