Douglas Gregor [Thu, 15 Dec 2011 18:03:09 +0000 (18:03 +0000)]
Introduce the core infrastructure needed to model a complete
redeclaration chain for Objective-C classes, including:
- Using the first declaration as the canonical declaration.
- Using the definition as the primary DeclContext
- Making sure that all declarations have a pointer to the definition
data, and the definition knows that it is the definition.
- Serialization support for when a definition gets added to a
declaration that comes from an AST file.
However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCInterfaceDecls.
Douglas Gregor [Thu, 15 Dec 2011 17:15:07 +0000 (17:15 +0000)]
Two null Decl*'s don't refer to the same declaration, because they
don't refer to anything. Amusingly, we were relying on this in one
place. Thanks to Chandler for noticing the weirdness in
declaresSameEntity.
Douglas Gregor [Thu, 15 Dec 2011 16:51:02 +0000 (16:51 +0000)]
Provide a default constructor for ObjCInterfaceDecl::DefinitionData
that value-initializes all of its members for which
default-initialization does not suffice. This should clean up the
failures for compilers that do not implement C++ DR543:
Douglas Gregor [Thu, 15 Dec 2011 05:27:12 +0000 (05:27 +0000)]
Move the definition-specific data of ObjCInterfaceDecl into a
separately-allocated DefinitionData structure, which we manage the
same way as CXXRecordDecl::DefinitionData. This prepares the way for
making ObjCInterfaceDecls redeclarable, to more accurately model
forward declarations of Objective-C classes and eliminate the mutation
of ObjCInterfaceDecl that causes us serious trouble in the AST reader.
Note that ObjCInterfaceDecl's accessors are fairly robust against
being applied to forward declarations, because Clang (and Sema in
particular) doesn't perform RequireCompleteType/hasDefinition() checks
everywhere it has to. Each of these overly-robust cases is marked with
a FIXME, which we can tackle over time.
Douglas Gregor [Thu, 15 Dec 2011 00:53:32 +0000 (00:53 +0000)]
In debugger support mode, if we have a top-level message send
expression with an unknown result type, assume that the result type is
'id'. Fixes <rdar://problem/10400663>.
Richard Trieu [Thu, 15 Dec 2011 00:38:15 +0000 (00:38 +0000)]
Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared. If either is a substring of the other, then
no error is given. This gives rise to an unexpected case:
// expect-error{{candidate function has different number of parameters}}
will match the following error messages from Clang:
candidate function has different number of parameters (expected 1 but has 2)
candidate function has different number of parameters
It will also match these other error messages:
candidate function
function has different number of parameters
number of parameters
This patch will change so that the verification string must be a substring of
the diagnostic message before accepting. Also, all the failing tests from this
change have been corrected. Some stats from this cleanup:
87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)
Douglas Gregor [Thu, 15 Dec 2011 00:29:59 +0000 (00:29 +0000)]
Replace all comparisons between ObjCInterfaceDecl pointers with calls
to declaresSameEntity(), as a baby step toward tracking forward
declarations of Objective-C classes precisely. Part of
<rdar://problem/10583531>.
Richard Smith [Wed, 14 Dec 2011 21:55:23 +0000 (21:55 +0000)]
Halve the constexpr recursion depth in this test in an attempt to make the
freebsd bots happy. In the longer term, we should have a mechanism for moving
constexpr recursion off the call stack, to support the default limit of 512
suggested by the standard.
Anna Zaks [Wed, 14 Dec 2011 18:34:17 +0000 (18:34 +0000)]
[analyzer] Re-enable the test which was failing on one of the bots.
I cannot reproduce the failures neither on my machine nor on the same buildbot machine (with the clang binary built on it). Let's see if it fails again..
Douglas Gregor [Wed, 14 Dec 2011 16:03:29 +0000 (16:03 +0000)]
When name lookup comes across a declaration that is in a module that
is not visible, look for any previous declarations of that entity that
might be visible.
Anna Zaks [Wed, 14 Dec 2011 00:56:18 +0000 (00:56 +0000)]
[analyzer] Treat stdin as a source of taint.
Some of the test cases do not currently work because the analyzer core
does not seem to call checkers for pre/post DeclRefExpr visits.
(Opened radar://10573500. To be fixed later on.)
Richard Trieu [Tue, 13 Dec 2011 23:19:45 +0000 (23:19 +0000)]
Make the diagnostic message more consistant. Update the type comparison to
handle non-pointer types. This is for the extra info printed when function
types are compared.
Ted Kremenek [Tue, 13 Dec 2011 14:50:33 +0000 (14:50 +0000)]
Tweak ARC diagnostic categories and rename 'Automatic Reference Counting Issue' to 'ARC Parse Issue' and 'ARC Issue' to 'ARC Semantic Issue'. Patch by Jean-Daniel Dupas.
Eli Friedman [Mon, 12 Dec 2011 23:13:20 +0000 (23:13 +0000)]
Make CGRecordLayoutBuilder correctly switch over to a packed class when a class has a base whose alignment will break the class layout. <rdar://problem/10551376>.
Suppress -Warray-bounds in certain cases involving macros from system headers.
The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large.
Chandler Carruth [Mon, 12 Dec 2011 04:28:35 +0000 (04:28 +0000)]
Update Clang to emit the new form of llvm.cttz and llvm.ctlz intrinsics,
setting the is_zero_undef flag appropriately to true as that matches the
semantics of these GCC builtins.
Anna Zaks [Sun, 11 Dec 2011 18:43:40 +0000 (18:43 +0000)]
[analyzer] CStringChecker should not rely on the analyzer generating UndefOrUnknown value when it cannot reason about the expression.
We are now often generating expressions even if the solver is not known to be able to simplify it. This is another cleanup of the existing code, where the rest of the analyzer and checkers should not base their logic on knowing ahead of the time what the solver can reason about.
In this case, CStringChecker is performing a check for overflow of 'left+right' operation. The overflow can be checked with either 'maxVal-left' or 'maxVal-right'. Previously, the decision was based on whether the expresion evaluated to undef or not. With this patch, we check if one of the arguments is a constant, in which case we know that 'maxVal-const' is easily simplified. (Another option is to use canReasonAbout() method of the solver here, however, it's currently is protected.)
This patch also contains 2 small bug fixes:
- swap the order of operators inside SValBuilder::makeGenericVal.
- handle a case when AddeVal is unknown in GenericTaintChecker::getPointedToSymbol.
Anna Zaks [Sat, 10 Dec 2011 23:36:51 +0000 (23:36 +0000)]
[analyzer] Introduce IntSymExpr, where the integer is on the lhs.
Fix a bug in SimpleSValBuilder, where we should swap lhs and rhs when calling generateUnknownVal(), - the function which creates symbolic expressions when data is tainted. The issue is not visible when we only create the expressions for taint since all expressions are commutative from taint perspective.
Refactor SymExpr::symbol_iterator::expand() to use a switch instead of a chain of ifs.
Richard Smith [Sat, 10 Dec 2011 01:10:13 +0000 (01:10 +0000)]
Add a fast path to the constant evaluator for integer literals. This speeds up
compilation of some translation units of SPEC's 445.gobmk by ~4%, and does not
seem to cause a measurable slowdown in other cases.
Douglas Gregor [Sat, 10 Dec 2011 00:23:21 +0000 (00:23 +0000)]
When we manage to re-use an expression during tree transformation (=
template instantiation), and that expression might produce a
temporary, invoke MaybeBindToTemporary. Otherwise, we forget to
destroy objects, release objects, etc. Fixes <rdar://problem/10531073>.
Daniel Dunbar [Fri, 9 Dec 2011 23:41:18 +0000 (23:41 +0000)]
Driver: Handle -f{no-}honor-infinities, -f{no-}honor-nans, and
-ffinite-math-only.
- No test case yet, I don't know how to construct a situation where this
matters.