Nick Lewycky [Fri, 12 Aug 2011 01:14:22 +0000 (01:14 +0000)]
The diagtool registration system tries to use a global variable from a method
called on another global variable. Use ManagedStatic to ensure that the global
we register with actually exists when we need it.
Anna Zaks [Fri, 12 Aug 2011 00:34:56 +0000 (00:34 +0000)]
Optimizations for Dependent Symbol tracking (as per Ted's code review for r137309):
1) Change SymbolDependTy map to keep pointers as data. And other small tweaks like making the DenseMap smaller 64->16 elements; remove removeSymbolDependencies() as it will probably not be used.
Douglas Gregor [Fri, 12 Aug 2011 00:15:20 +0000 (00:15 +0000)]
In the serialized AST format, make the translation unit a "predefined"
declaration that never actually gets serialized. Instead, serialize
the various kinds of update records (lexical decls, visible decls, the
addition of an anonymous namespace) for the translation unit, even if
we're not chaining. This way, we won't have to deal with multiple
loaded translation unit declarations.
Richard Trieu [Thu, 11 Aug 2011 22:38:21 +0000 (22:38 +0000)]
The current warning in -Wnull-arithmetic for comparisons between NULL and non-pointers is not very helpful. This patch will update the wording to be more helpful to users.
Old warning:
warning: use of NULL in arithmetic operation [-Wnull-arithmetic]
return 10 <= NULL;
^ ~~~~
New warning:
warning: comparison between NULL and non-pointer ('int' and NULL) [-Wnull-arithmetic]
return 10 <= NULL;
~~ ^ ~~~~
Douglas Gregor [Thu, 11 Aug 2011 22:18:49 +0000 (22:18 +0000)]
When initializing a context from a particular AST file, check whether
either "special" type has already been initialized. Previously, we did
this check based on just the first special type (__builtin_va_list),
but now we have some NULL special type entries to content with.
Douglas Gregor [Thu, 11 Aug 2011 20:58:55 +0000 (20:58 +0000)]
Encapsulate the Objective-C id/Class/SEL "redefinition" types in
ASTContext with accessors/mutators. The only functional change is that
the AST writer won't bother writing the id/Class/SEL redefinition type
if it hasn't been explicitly set; previously, it ended up being
written as a synonym for the built-in id/Class/SEL.
Anna Zaks [Thu, 11 Aug 2011 16:43:28 +0000 (16:43 +0000)]
Analyzer Core: Adding support for user-defined symbol dependencies. (For example, the allocated resource symbol only needs to be freed if no error has been returned by the allocator, so a checker might want to make the lifespan of the error code symbol depend on the allocated resource symbol.) Note, by default, the map that holds the dependencies will get destroyed along with the SymbolManager at the end of function exploration.
John McCall [Thu, 11 Aug 2011 02:22:43 +0000 (02:22 +0000)]
Simplify EH control flow by observing that EH scopes form a simple
hierarchy of delegation, and that EH selector values are meaningful
function-wide (good thing, too, or inlining wouldn't work).
2,3d
1a
hierarchy of delegation and that EH selector values have the same
meaning everywhere in the function instead of being meaningful only
in the context of a specific selector.
This removes the need for routing edges through EH cleanups,
since a cleanup simply always branches to its enclosing scope.
Anna Zaks [Wed, 10 Aug 2011 23:14:54 +0000 (23:14 +0000)]
Analyzer Core: In checkDeadSymbols checker callback, provide the state in which the symbols are not yet deleted so that checkers could inspect them. Since we are now always creating a transition in ProcessStmt(), remove the logic for adding a transition when none was generated. TODO: the extra transitions will have to be removed; more cleanups; a checker that tests teh new fucntionality.
Douglas Gregor [Wed, 10 Aug 2011 21:59:45 +0000 (21:59 +0000)]
When performing the lookup in the current scope for a member access to
a member template, e.g.,
x.f<int>
if we have found a template in the type of x, but the lookup in the
current scope is ambiguous, just ignore the lookup in the current
scope. Fixes <rdar://problem/9915664>.
[arcmt] When checking whether properties needs to be strong or not, take into account
that assigning result of -retain means it should be strong. rdar://9931757.
objective-c: Using existing infrastructure for finding
overridden methods to diagnose their type mismatch.
This is a general solution for previous fixes
for // rdar://6191214 and // rdar://9352731
and removes lots of duplicate code.
Douglas Gregor [Wed, 10 Aug 2011 16:59:20 +0000 (16:59 +0000)]
Expand test of C++0x [class.copymove]p15 to make sure we're actually calling the copy constructor of a base/member from an explicitly-defaulted copy constructor, rather than the default constructor
Douglas Gregor [Wed, 10 Aug 2011 16:51:53 +0000 (16:51 +0000)]
When adding the base and member initializers for an implicitly-defined
special member function, make sure to classify an explicitly-defaulted
copy constructor as a "copy" operation. Fixes PR10622.
Douglas Gregor [Wed, 10 Aug 2011 15:22:55 +0000 (15:22 +0000)]
Rewrite default initialization of anonymous structs/unions within a
constructor. Previously, we did some bogus recursion into the fields
of anonymous structs (recursively), which ended up building invalid
ASTs that would cause CodeGen to crash due to invalid GEPs.
Now, we instead build the default initializations based on the
indirect field declarations at the top level, which properly generates
the sequence of GEPs needed to initialize the proper member. Fixes
PR10512 and <rdar://problem/9924046>.
John McCall [Wed, 10 Aug 2011 04:12:23 +0000 (04:12 +0000)]
Change an assert into a check. I'm pretty sure there was a point
in time when this assert was valid, but it's not valid now.
Also teach this code to correctly introduce function-to-pointer
decay.
Thread Safety: Added basic argument parsing for all new attributes.
This patch special cases the parser for thread safety attributes so that all
attribute arguments are put in the argument list (instead of a special
parameter) since arguments may not otherwise resolve correctly without two-token
lookahead.
This patch also adds checks to make sure that attribute arguments are
lockable objects.
Douglas Gregor [Tue, 9 Aug 2011 17:23:49 +0000 (17:23 +0000)]
Move the creation of the record type for the state of Objective-C fast
enumerations from the ASTContext into CodeGen, so that we don't need
to serialize it to AST files. This appears to be the last of the
low-hanging fruit for SpecialTypes.
Douglas Gregor [Tue, 9 Aug 2011 16:24:26 +0000 (16:24 +0000)]
Don't serialize the block descriptor or block extended descriptor
types to AST files; they're only used by debug info generation anyway,
and shouldn't ever exist in the AST anyway.
Douglas Gregor [Tue, 9 Aug 2011 15:54:21 +0000 (15:54 +0000)]
Move the construction of the RecordDecl representing the runtime
layout of a constant NSString from the ASTContext over to CodeGen,
since this is solely CodeGen's responsibility. Eliminates one of the
unnecessary "special" types that we serialize.
Douglas Gregor [Tue, 9 Aug 2011 15:13:55 +0000 (15:13 +0000)]
Migrate the serialization of ASTContext's AutoDeduceTy and
AutoRRefDeductTy from the "special types" block to predefined
types. The latter behaves better when loading multiple AST files.
Don't emit memcpy for copying fields of arrays of volatile elements.
Use the the path that generates a loop. This fixes
bogus error that clang puts out. // rdar://9894548
objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance)
"conformsTo" two protocols which conflict (have methods which conflict).
This patch fixes the previous patch where warnings were coming out in
non-deterministic order. This is 2nd part of // rdar://6191214.
David Chisnall [Mon, 8 Aug 2011 17:32:19 +0000 (17:32 +0000)]
Silence the category-replacing-class-method warning for +load: category
implementations of +load do not replace the class definition in a meaningful
sense, they are run when the category loads, the +load method for class is run
when the class is loaded.
John McCall [Sat, 6 Aug 2011 07:30:58 +0000 (07:30 +0000)]
Do l-value conversion, etc., on a switch condition expression in
ActOnStartOfSwitchStmt (i.e. before binding up a full-expression)
instead of ActOnFinishSwitchStmt.
Among other things, this means that property l-values are properly
converted inside the full-expression.
Ted Kremenek [Sat, 6 Aug 2011 06:54:45 +0000 (06:54 +0000)]
[analyzer] Start sketching out a new BugReporterVisitor that inspects branches and other expressions to generate interesting path events in diagnostics.
John McCall [Sat, 6 Aug 2011 06:53:52 +0000 (06:53 +0000)]
Be sure to destroy the normal entry block of a cleanup that we
aren't actually going to make a normal cleanup for. Sometimes
we optimistically create branches to such blocks for fixups,
and then we resolve the fixup to somewhere within the cleanup's
scope, and then the cleanup is actually not reachable for some
reason. The process of resolving the fixup leaves us with
switches whose default edge leads to the cleanup; we can
replace that with unreachable, then (in many cases) turn
the switch into an unconditional branch.
Ted Kremenek [Sat, 6 Aug 2011 00:29:57 +0000 (00:29 +0000)]
[analyzer] Change SymbolReaper to store region roots implied by the Environment, allowing it be queried when
determining if symbols derived from regions are still live.
Anna Zaks [Fri, 5 Aug 2011 23:52:45 +0000 (23:52 +0000)]
KeychainAPI checker: Track SymbolMetadata instead of MemRegion in checker state so that we could clear the state on evalDeadSymbols; also track the return value.
Kaelyn Uhrain [Fri, 5 Aug 2011 23:18:04 +0000 (23:18 +0000)]
Perform array bounds checking in more situations and properly handle special
case situations with the unary operators & and *. Also extend the array bounds
checking to work with pointer arithmetic; the pointer arithemtic checking can
be turned on using -Warray-bounds-pointer-arithmetic.
The changes to where CheckArrayAccess gets called is based on some trial &
error and a bunch of digging through source code and gdb backtraces in order
to have the check performed under as many situations as possible (such as for
variable initializers, arguments to function calls, and within conditional in
addition to the simpler cases of the operands to binary and unary operator)
while not being called--and triggering warnings--more than once for a given
ArraySubscriptExpr.
Chad Rosier [Fri, 5 Aug 2011 22:38:04 +0000 (22:38 +0000)]
Add support for using anonymous bitfields (e.g., int : 0) to enforce alignment.
This fixes cases where the anonymous bitfield is followed by a bitfield member.
E.g.,
struct t4
{
char foo;
long : 0;
char bar : 1;
};
Ted Kremenek [Fri, 5 Aug 2011 21:53:47 +0000 (21:53 +0000)]
Make test/SemaObjC/qualified-protocol-method-conflicts.m always fail and mark it XFAIL. This is a stop gap until the output of the test is deterministic.
Flesh out the -Warray-bounds detection of C89 tail-padded one-element
arrays. This now suppresses the warning only in the case of
a one-element array as the last field in a struct where the array size
is a literal '1' rather than any macro expansion or template parameter.
This doesn't distinguish between the language standard in use to allow
code which dates from C89 era to compile without the warning even in C99
and C++ builds. We could add a separate warning (under a different flag)
with fixit hints to switch to a flexible array, but its not clear that
this would be desirable. Much of the code using this idiom is striving
for maximum portability.
Tests were also fleshed out a bit, and the diagnostic itself tweaked to
be more pretty w.r.t. single elment arrays. This is more ugly than
I would like due to APInt's not being supported by the diagnostic
rendering engine.
A pseudo-patch for this was proposed by Nicola Gigante, but I reworked
it both for several correctness issues and for code style.
Finally getting around to re-working this to more accurately white-list
1-element character arrays which are serving as flexible arrays. This is
the initial step, which is to restrict the 1-element array whitelist to
arrays that are member declarations. I'll refine it from here based on
the proposed patch.
Kaelyn Uhrain [Thu, 4 Aug 2011 23:30:54 +0000 (23:30 +0000)]
Fix a small bug where DiagnoseEmptyLookup would no longer print any messages
when performing typo correction involving any overloaded template functions.
The added test cases, while currently demontrating sub-optimal behavior, will
not trigger any messages without the 1-line change to SemaExpr.cpp.
Anna Zaks [Thu, 4 Aug 2011 21:53:01 +0000 (21:53 +0000)]
KeychainAPI checker: Track additional pair of SecKeychain APIs. Also, keep exploring the transition on which a call to allocator function failed (to be able to find errors in examples like ErrorCodesFromDifferentAPISDoNotInterfere).