Aaron Ballman [Tue, 28 Aug 2012 20:55:40 +0000 (20:55 +0000)]
Splitting the duplicated decl spec extension warning into two: one is an ExtWarn and the other a vanilla warning. This addresses PR13705, where const char const * wouldn't warn unless -pedantic was specified under the right conditions.
Jordan Rose [Tue, 28 Aug 2012 20:52:21 +0000 (20:52 +0000)]
[analyzer] Teach CallEventManager that CXXTemporaryObjectExpr is also a ctor.
Specifically, CallEventManager::getCaller was looking at the call site for
an inlined call and trying to see what kind of call it was, but it only
checked for CXXConstructExprClass. (It's not using an isa<> here to avoid
doing three more checks on the the statement class.)
This caused an unreachable when we actually did inline the constructor of a
temporary object.
Jordan Rose [Tue, 28 Aug 2012 20:52:13 +0000 (20:52 +0000)]
[analyzer] When we look for the last stmt in a function, skip implicit dtors.
When exiting a function, the analyzer looks for the last statement in the
function to see if it's a return statement (and thus bind the return value).
However, the search for "the last statement" was accepting statements that
were in implicitly-generated inlined functions (i.e. destructors). So we'd
go and get the statement from the destructor, and then say "oh look, this
function had no explicit return...guess there's no return value". And /that/
led to the value being returned being declared dead, and all our leak
checkers complaining.
CUDA: give static storage class to __shared__ and __constant__
variables without a storage class within a function, to implement
CUDA B.2.5: "__shared__ and __constant__ variables have implied static
storage [duration]."
Chad Rosier [Tue, 28 Aug 2012 20:33:49 +0000 (20:33 +0000)]
[ms-inline asm] Have generateAsmString() return the AsmString computed by Sema.
We still need to translate the string, but this at least gets us one step
closer to using the more general EmitAsmStmt() codegen function. No functional
change intended.
Chad Rosier [Tue, 28 Aug 2012 20:28:20 +0000 (20:28 +0000)]
[ms-inline asm] Add constraints to MSAsmStmt. We don't currently compute
the constraints, so in the interim we speculatively assume a 'r' constraint.
This is expected to work for most cases on x86.
Chad Rosier [Tue, 28 Aug 2012 18:54:39 +0000 (18:54 +0000)]
[ms-inline asm] Rename EmitGCCAsmStmt to EmitAsmStmt and have it accept
AsmStmts. This function is only used by GCCAsmStmts, however. Constraints need
to be properly computed before MSAsmStmts can use EmitAsmStmt. No functional
change intended.
Jordan Rose [Tue, 28 Aug 2012 18:16:45 +0000 (18:16 +0000)]
[analyzer] Don't purge dead symbols at the end of calls if -analyzer-purge=none.
No test case since this is a debug option that we will never turn on by
default since it makes the leak checkers much less useful. (We'll only report
leaks at the end of analysis if -analyzer-purge=none.)
Hans Wennborg [Tue, 28 Aug 2012 15:44:30 +0000 (15:44 +0000)]
Warn about suspicious implicit conversions from floating point to bool
This warns in two specific situations:
1) For potentially swapped function arguments, e.g.
void foo(bool, float);
foo(1.7, false);
2) Misplaced brackets around function call arguments, e.g.
bool InRange = fabs(a - b < delta);
Where the last argument in a function call is implicitly converted
from bool to float, and the function returns a float which gets
implicitly converted to bool.
Jordan Rose [Tue, 28 Aug 2012 00:50:51 +0000 (00:50 +0000)]
[analyzer] Rename addTrackNullOrUndefValueVisitor to trackNullOrUndefValue.
This helper function (in the clang::ento::bugreporter namespace) may add more
than one visitor, but conceptually it's tracking a single use of a null or
undefined value and should do so as best it can.
Also, the BugReport parameter has been made a reference to underscore that
it is non-optional.
Jordan Rose [Tue, 28 Aug 2012 00:50:45 +0000 (00:50 +0000)]
[analyzer] Refactor FindLastStoreBRVisitor to not find the store ahead of time.
As Anna pointed out to me offline, it's a little silly to walk backwards through
the graph to find the store site when BugReporter will do the exact same walk
as part of path diagnostic generation.
Jordan Rose [Tue, 28 Aug 2012 00:50:38 +0000 (00:50 +0000)]
[analyzer] Rename CallEvent::mayBeInlined to CallEvent::isCallStmt.
The two callers are using this in order to be conservative, so let's just
clarify the information that's actually being provided here. This is not
related to inlining decisions in any way.
[libclang] When determining the cursor via a location, ignore synthesized ivars otherwise
if we have something like:
@synthesize prop = _prop;
and '_prop' is not declared, we will encounter a '_prop' ivar before
encountering the 'prop' synthesize declaration and we will think that
we passed the region-of-interest, missing the cursor for 'prop'.
Simon Atanasyan [Mon, 27 Aug 2012 20:55:56 +0000 (20:55 +0000)]
MIPS: Use -G option to specify MIPS section threshold. Translate it
to the -mllvm -mips-ssection-threshold=<value> pair and pass to the frontend.
The patch suggested by Carl Norum.
Chad Rosier [Mon, 27 Aug 2012 20:23:31 +0000 (20:23 +0000)]
[ms-inline asm] Rename GenerateAsmString to generateAsmString to conform with
coding standards. Also, add stub for MSAsmStmt class as part of unifying
codegen logic for AsmStmts.
Manuel Klimek [Mon, 27 Aug 2012 18:49:12 +0000 (18:49 +0000)]
This is a temporary solution until we have a better way to
parse doxygen comments for macros with libclang.
I'm not entirely happy about this script, but as it saves
a lot of work in keeping the docs up to date with the
actual code I think checking it in makes sense.
Jordan Rose [Mon, 27 Aug 2012 18:39:22 +0000 (18:39 +0000)]
[analyzer] Don't inline constructors for objects allocated with operator new.
Because the CXXNewExpr appears after the CXXConstructExpr in the CFG, we don't
actually have the correct region to construct into at the time we decide
whether or not to inline. The long-term fix (discussed in PR12014) might be to
introduce a new CFG node (CFGAllocator) that appears before the constructor.
Tracking the short-term fix in <rdar://problem/12180598>.
Jordan Rose [Mon, 27 Aug 2012 17:50:07 +0000 (17:50 +0000)]
[analyzer] Inline constructors for any object with a trivial destructor.
This allows us to better reason about status objects, like Clang's own
llvm::Optional (when its contents are trivially destructible), which are
often intended to be passed around by value.
We still don't inline constructors for temporaries in the general case.
Jordan Rose [Sat, 25 Aug 2012 01:06:23 +0000 (01:06 +0000)]
[analyzer] Use the common evalBind infrastructure for initializers.
This allows checkers (like the MallocChecker) to process the effects of the
bind. Previously, using a memory-allocating function (like strdup()) in an
initializer would result in a leak warning.
This does bend the expectations of checkBind a bit; since there is no
assignment expression, the statement being used is the initializer value.
In most cases this shouldn't matter because we'll use a PostInitializer
program point (rather than PostStmt) for any checker-generated nodes, though
we /will/ generate a PostStore node referencing the internal statement.
(In theory this could have funny effects if someone actually does an
assignment within an initializer; in practice, that seems like it would be
very rare.)
Richard Smith [Sat, 25 Aug 2012 00:32:28 +0000 (00:32 +0000)]
-fcatch-undefined-behavior: add the -ftrapv checks to the set of things caught
by this mode, and also check for signed left shift overflow. The rules for the
latter are a little subtle:
* neither C89 nor C++98 specify the behavior of a signed left shift at all
* in C99 and C11, shifting a 1 bit into the sign bit has undefined behavior
* in C++11, with core issue 1457, shifting a 1 bit *out* of the sign bit has
undefined behavior
As of this change, we use the C99 rules for all C language variants, and the
C++11 rules for all C++ language variants. Once we have individual
-fcatch-undefined-behavior= flags, this should be revisited.
objective-C: Do not warn if align attribute on method
declaration is not provided. It is only necessary on
the method implementation. // rdar://11593375
John McCall [Fri, 24 Aug 2012 22:54:02 +0000 (22:54 +0000)]
When computing the effective context for access control,
make sure we walk up the DC chain for the current context,
rather than allowing ourselves to get switched over to the
canonical DC chain. Fixes PR13642.
Chad Rosier [Fri, 24 Aug 2012 21:42:51 +0000 (21:42 +0000)]
[ms-inline asm] Change the -fenable-experimental-ms-inline-asm option from a
CodeGen option to a LangOpt option. In turn, hoist the guard into the parser
so that we avoid the new (and fairly unstable) Sema/AST/CodeGen logic. This
should restore the behavior of clang to that prior to r158325.
<rdar://problem/12163681>
objective-C: When checking for valid overriden property
in class extension, assume default is rewdwrite and don't
issue any diagnostics, privided other ownership models
are ok.
Ted Kremenek [Fri, 24 Aug 2012 19:46:03 +0000 (19:46 +0000)]
Rename the "experimental" checker package to "alpha". We will then refine
this group into "alpha" and "beta" to distinguish between checkers in
different levels of premature state.
Ted Kremenek [Fri, 24 Aug 2012 19:35:19 +0000 (19:35 +0000)]
Rework how PathDiagnosticConsumers pass knowledge of what files they
generated for a given diagnostic to another. Because PathDiagnostics
are specific to a give PathDiagnosticConsumer, store in
a FoldingSet a unique hash for a PathDiagnostic (that will be the same
for the same bug for different PathDiagnosticConsumers) that
stores a list of files generated. This can then be read by the
other PathDiagnosticConsumers.
Jordan Rose [Fri, 24 Aug 2012 16:34:31 +0000 (16:34 +0000)]
[analyzer] If we dereference a NULL that came from a function, show the return.
More generally, any time we try to track where a null value came from, we
should show if it came from a function. This usually isn't necessary if
the value is symbolic, but if the value is just a constant we previously
just ignored its origin entirely. Now, we'll step into the function and
recursively add a visitor to the returned expression.