Ted Kremenek [Thu, 24 Feb 2011 03:09:15 +0000 (03:09 +0000)]
Fix tiny error in CFG construction for BinaryConditionalOperators, making sure the branch always has two successors. Also teach Environment::getSVal() about OpaqueValueExprs.
This fixes a crash reported in PR9287, and also fixes a false positive involving the value of such ternary
expressions not properly getting propagated.
Douglas Gregor [Thu, 24 Feb 2011 02:36:08 +0000 (02:36 +0000)]
Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.
Ken Dyck [Thu, 24 Feb 2011 02:12:14 +0000 (02:12 +0000)]
Use CharUnits values for Size and DataSize outside of the bitfield layout
methods, when they are known to be exact multiples of the width of the char
type.
Ken Dyck [Thu, 24 Feb 2011 01:13:28 +0000 (01:13 +0000)]
Make the Size and DataSize members more CharUnits-friendly by wrapping them
with getter and setter methods in both bit units and CharUnits. This will help
simplify some of the unit mismatch in the parts of the code where sizes are
known to be exact multiples of the width of the char type.
Assertions in the getters help guard against accidentally converting to
CharUnits when sizes are not exact multiples of the char width.
Douglas Gregor [Thu, 24 Feb 2011 00:17:56 +0000 (00:17 +0000)]
Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.
Chandler Carruth [Wed, 23 Feb 2011 23:52:14 +0000 (23:52 +0000)]
Clean up the CMake test execution by nuking this directory before we try
to create it. Lit doesn't apparently clean up test directories
effectively, and so this broke randomly on subsequent runs.
Also XFAIL the test on windows, as there's not much hope for these
commands doing the right thing there.
Chandler Carruth [Wed, 23 Feb 2011 23:34:11 +0000 (23:34 +0000)]
Implement a warning for known shift overflows on constant shift
expressions. Consider the code:
int64_t i = 10 << 30;
This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.
The warning is currently gated behind -Wshift-overflow.
There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.
Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.
-Introduce EndOfFunctionNodeBuilder::withCheckerTag to allow it be "specialized" with a
checker tag and not require the checkers to pass a tag.
-For EndOfFunctionNodeBuilder::generateNode, reverse the order of tag/P parameters since
there are actual calls that assume the second parameter is ExplodedNode.
Chandler Carruth [Wed, 23 Feb 2011 18:51:59 +0000 (18:51 +0000)]
Fix the behavior of -Wignored-qualifiers on return type qualifiers in
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.
Patch by Hans Wennborg, a couple of minor style tweaks from me.
Ted Kremenek [Wed, 23 Feb 2011 05:11:46 +0000 (05:11 +0000)]
Teach CFGBuilder about null pointer constants in conditionals, and how they can be used to prune branches. Fixes false null pointer dereference warning in PR 8183.
Ted Kremenek [Wed, 23 Feb 2011 01:52:04 +0000 (01:52 +0000)]
Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the related code is reachable. This suppresses some
diagnostics that occur in unreachable code (e.g., -Warray-bound).
We only pay the cost of doing the reachability analysis when we issue one of these diagnostics.
Ted Kremenek [Wed, 23 Feb 2011 01:51:40 +0000 (01:51 +0000)]
Change -Warray-bounds logic to use DiagRuntimeBehavior in preparation for using basic dataflow to suppress warnings on unreachable array bounds checks.
Chandler Carruth [Wed, 23 Feb 2011 00:47:48 +0000 (00:47 +0000)]
Switch the VerifyDiagnosticsClient to use PresumedLocs now that they
exist. Cheat and do this by adding some wrappers around the PresumedLoc
machinery that directly return the line and column number.
[analyzer] Refactor BugTypes and their ownership model.
-In general, don't have the BugReporter deleting BugTypes, BugTypes will eventually become owned by checkers
and outlive the BugReporter. In the meantime, there will be some leaks since some checkers assume that
the BugTypes they create will be destroyed by the BugReporter.
-Have BugReporter::EmitBasicReport create BugTypes that are reused if the same name & category strings
are passed to EmitBasicReport. These BugTypes are owned and destroyed by the BugReporter.
This allows bugs reported through EmitBasicReport to be coalesced.
-Remove the llvm::FoldingSet<BugReportEquivClass> from BugType and move it into the BugReporter.
For uniquing BugReportEquivClass also use the BugType* so that we can iterate over all of them using only one set.
Clean up the error recovery at the bottom of Sema::LookupMemberExpr. This
mostly just shuffles various possibilities for recovery into a more
straightforward order, but also unifies a couple of diagnostics.
Douglas Gregor [Tue, 22 Feb 2011 23:21:06 +0000 (23:21 +0000)]
When checking for abstract types, don't crash when we have a
FunctionProtoTypeLoc with NULL function parameter types, which can
occur in invalid code. Fixes PR9247 / <rdar://problem/9037911>.
John McCall [Tue, 22 Feb 2011 22:38:33 +0000 (22:38 +0000)]
Emit the structure layout of the block literal parameter to a block
invocation function into the debug info. Rather than faking up a class,
which is tricky because of the custom layout we do, we just emit a struct
directly from the layout information we've already got.
Also, don't emit an unnecessarily parameter alloca for this "variable".
[analyzer] Start moving the path-sensitive checkers to CheckerV2.
-Migrate ObjCSelfInitChecker to CheckerV2. In the process remove the 'preCallSelfFlags' field
from the checker class and use GRState for storing that info.
-Get ExprEngine to start delegating checker running to CheckerManager.
Douglas Gregor [Tue, 22 Feb 2011 02:55:24 +0000 (02:55 +0000)]
Fix a little bug in the handling of enumeration types with a fixed
underlying type: we weren't parsing unnamed enumeration types with a
fixed underlying type.
Bug#8945: Add -cxx-isystem option to specify C++ system directories.
It works like -isystem and the search path keeps -isystem and
-cxx-isystem in order relative to each other. -cxx-isystem is only used
for C++ sources though. Drop the existing -cxx-system-include option for
cc1 as it is now redundant.
Richard Smith [Tue, 22 Feb 2011 00:36:53 +0000 (00:36 +0000)]
Fix a few auto-related issues:
* 'auto' was being rejected on abstract-declarators with trailing return
types and on typedefs with trailing return types. 'auto' is always
allowed in these cases. This was found while testing the fix for PR 9278.
* A very poor diagnostic was being issued for auto (f() -> int): "return
type must be 'auto', not 'auto'". This is closely related to PR 9060.
* Trailing return type handling was happening slightly too late,
resulting in the checks for functions returning arrays and functions
returning functions being missed.
Chris Lattner [Mon, 21 Feb 2011 22:09:29 +0000 (22:09 +0000)]
add one more case of mismatched input/output constraints.
When the mismatch is due to a larger input operand that is
a constant, truncate it down to the size of the output. This
allows us to accept some cases in the linux kernel and elsewhere.
Pedantically speaking, we generate different code than GCC, though
I can't imagine how it would matter: