Anna Zaks [Sat, 17 Dec 2011 00:26:34 +0000 (00:26 +0000)]
[analyzer] Add support for taint flowing through a function (atoi).
Check if the input parameters are tainted (or point to tainted data) on
a checkPreStmt<CallExpr>. If the output should be tainted, record it in
the state. On post visit (checkPostStmt<CallExpr>), use the state to
make decisions (in addition to the existing logic). Use this logic for
atoi and fscanf.
Chad Rosier [Sat, 17 Dec 2011 00:15:26 +0000 (00:15 +0000)]
Fix _mm256_round_pd, _mm256_round_ps, _mm_permute_pd and _mm256_permute_pd AVX
intrinsics to use "I" (ICE) markings. Fix avxintrin.h to take them into
account.
Part of rdar://10595450
Eric Christopher [Fri, 16 Dec 2011 23:40:18 +0000 (23:40 +0000)]
When in a limited debug information situation if we can find the original
declaration for the type then go ahead and use that, it's still smaller
than creating an all new derived type.
Richard Smith [Fri, 16 Dec 2011 22:50:01 +0000 (22:50 +0000)]
Don't allow #include (and its friends #import, #include_next and
#__include_macros) in the arguments of a function-style macro. Directives in the
arguments of such macros have undefined behaviour, and GCC does not correctly
support these cases. In some situations, this can lead to better diagnostics.
Nick Lewycky [Fri, 16 Dec 2011 22:34:14 +0000 (22:34 +0000)]
Add the value of "suitably aligned" from the C++11 standard to Basic/TargetInfo.
This is equal to alignof(std::max_align_t) on the platform and equal to the
alignment provided by malloc. (Platform owners please double-check your
platform's value.)
Richard Smith [Fri, 16 Dec 2011 20:58:01 +0000 (20:58 +0000)]
Add a warning flag for ext_embedded_directive. gcc considers this undefined
behaviour to be an error, so it's useful to be able to make it an error in clang
too.
Richard Smith [Fri, 16 Dec 2011 19:31:14 +0000 (19:31 +0000)]
PR11594: Don't blindly build a UnaryOperator UO_Minus on an expression which
might not be an rvalue when checking array accesses. Instead, pass through a
flag indicating the array index is negated.
Richard Smith [Fri, 16 Dec 2011 19:06:07 +0000 (19:06 +0000)]
C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.
Sean Callanan [Fri, 16 Dec 2011 00:20:31 +0000 (00:20 +0000)]
Sema::RequireCompleteType currently attempts to
instantiate a class from its template pattern
before it consults the ExternalASTSource. LLDB
in particular will sometimes provide patterns
that need to be completed first.
To make this possible, I have moved the
completion before the code that does the
instantiation, allowing the ExternalASTSource
to provide the required information.
Douglas Gregor [Thu, 15 Dec 2011 22:34:59 +0000 (22:34 +0000)]
Move ObjCInterfaceDecl's "EndLoc" into DefinitionData, since it only
applies to an actual definition. Plus, clarify the purpose of this
field and give the accessor a different name, since getLocEnd() is
supposed to be the same as getSourceRange().getEnd().
Douglas Gregor [Thu, 15 Dec 2011 20:29:51 +0000 (20:29 +0000)]
Keep track of all declarations of an Objective-C class (both forward
declarations and definitions) as ObjCInterfaceDecls within the same
redeclaration chain. This new representation matches what we do for
C/C++ variables/functions/classes/templates/etc., and makes it
possible to answer the query "where are all of the declarations of
this class?"
Douglas Gregor [Thu, 15 Dec 2011 18:17:27 +0000 (18:17 +0000)]
Extend ObjCInterfaceDecl::DefinitionData to contain a pointer to the
definition, and implement ObjCInterfaceDecl::getDefinition()
efficiently based on that.
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.