objective-c modern translator: Refactor intername ivar names to
one place and use it throughout. Also, change ivar name to avoid
name collisions. // rdar://11079366
Chad Rosier [Tue, 20 Mar 2012 16:40:00 +0000 (16:40 +0000)]
[avx] Define the _mm256_loadu2_xxx and _mm256_storeu2_xxx intrinsics.
From the Intel Optimization Reference Manual, Section 11.6.2. When data cannot
be aligned or alignment is not known, 16-byte memory accesses may provide better
performance.
rdar://11076953
Ted Kremenek [Mon, 19 Mar 2012 23:48:41 +0000 (23:48 +0000)]
Fix crash when querying the CFG reported when using the thread safety analysis
on code using multi-dimensional arrays. Fix by DeLesley Hutchins, and reported in
PR 12271.
Jordy Rose [Sun, 18 Mar 2012 07:43:35 +0000 (07:43 +0000)]
[analyzer] Mark a failed-realloc's result as an interesting symbol between the realloc call and the null check, so we get nicer path notes. Fixes a regression introduced by the diagnostic pruning added in r152361.
This is accomplished by calling markInteresting /during/ path diagnostic generation, and as such relies on deterministic ordering of BugReporterVisitors -- namely, that BugReporterVisitors are run in /reverse/ order from how they are added. (Right now that's a consequence of storing visitors in an ImmutableList, where new items are added to the front.) It's a little hacky, but it works for now.
I think this is the best we can do without storing the relation between the old and new symbols, and that would be a hit whether or not there ends up being an error.
David Blaikie [Sun, 18 Mar 2012 02:56:47 +0000 (02:56 +0000)]
Use character literals for vexing initialization fixit hints.
Instead of suggesting " = 0" for "char c();", suggest " = '\0'", and similarly
for other char types (wide, 16, and 32). Add tests for all these, and since
this means testing such hints under C++0x, add tests for some untested C++0x
hint cases in the existing code, including suggesting nullptr for pointer
initialization.
This sets up the initialization helper to provide better type fidelity that
will be especially helpful for non-assignment cases (such as fixit-correcting
NULL usage in function calls (eg: foo(char) + foo(NULL) => foo('\0') instead
of the less informative foo(0)))
Jordy Rose [Sun, 18 Mar 2012 01:26:10 +0000 (01:26 +0000)]
[analyzer] Use a FoldingSet to cache simple RetainSummary instances, rather than explicitly keeping DoNothing and StopTracking summaries and nothing else.
I tried to test the effects of this change on memory usage and run time, but what I saw on retain-release.m was indistinguishable from noise (debug and release builds). Even so, some caveman profiling showed 101 cache hits that we would have generated new summaries for before (i.e. not default or stop summaries), and the more code we analyze, the more memory we should save.
Maybe we should have a standard project for benchmarking the retain count checker's memory and time?
Jordy Rose [Sat, 17 Mar 2012 20:51:32 +0000 (20:51 +0000)]
Kill cocoa::deriveNamingConvention and cocoa::followsFundamentalRule. They are now just simple wrappers around method families, and method decls can cache method family lookups. Also, no one is using them right now.
The one difference between ObjCMethodDecl::getMethodFamily and Selector::getMethodFamily is that the former will do some additional sanity checking, and since CoreFoundation types don't look like Objective-C objects, an otherwise interesting method will get a method family of OMF_None. Future clients that use method families should consider how they want to handle CF types.
Jordy Rose [Sat, 17 Mar 2012 19:53:04 +0000 (19:53 +0000)]
[analyzer] Remove duplicate work on deriving method behavior. No functionality change.
The cocoa::deriveNamingConventions helper is just using method families anyway now, and the way RetainSummaryTemplate works means we're allocating an extra summary for every method with a relevant family.
Also, fix RetainSummaryTemplate to do the right thing w/r/t annotating an /existing/ summary. This was probably the real cause of <rdar://problem/10824732> and the fix in r152448.
modern objective-c rewriter: further improvement in
writing @synchronized statement; do not call locking
expression more than once and support early exits in
@synchronized's statement block (such as return).
Anna Zaks [Fri, 16 Mar 2012 23:24:20 +0000 (23:24 +0000)]
[analyzer] Create symbol-aware stack hints (building upon r152837).
The symbol-aware stack hint combines the checker-provided message
with the information about how the symbol was passed to the callee: as
a parameter or a return value.
For malloc, the generated messages look like this :
"Returning from 'foo'; released memory via 1st parameter"
"Returning from 'foo'; allocated memory via 1st parameter"
"Returning from 'foo'; allocated memory returned"
"Returning from 'foo'; reallocation of 1st parameter failed"
(We are yet to handle cases when the symbol is a field in a struct or
an array element.)
Benjamin Kramer [Fri, 16 Mar 2012 22:31:42 +0000 (22:31 +0000)]
Escape % in diagnostic message when compiling LLVM IR.
% is a common character in IR so we'd crash on almost any malformed IR. The
diagnostic formatter expects a formatting directive when it sees an unescaped %.
Bill Wendling [Fri, 16 Mar 2012 21:45:12 +0000 (21:45 +0000)]
When "low alignment" is specified, then set the alignment of the aggregate's
store to 1. This allows code-gen to select a more appropriate alignment. If left
to zero, an alignment greater than the alignment of the pointer may be selected,
causing code-gen to use instructions which require an alignment greater than the
pointer guarantees.
<rdar://problem/11043589>
David Blaikie [Fri, 16 Mar 2012 20:30:12 +0000 (20:30 +0000)]
Suppress macro expansion of NULL in NULL warnings.
For "int i = NULL;" we would produce:
null.cpp:5:11: warning: implicit conversion of NULL constant to integer [-Wconversion]
int i = NULL;
~ ^~~~
null.cpp:1:14: note: expanded from macro 'NULL'
\#define NULL __null
^~~~~~
But we really shouldn't trace that macro expansion back into the header, yet we
still want macro back traces for code like this:
\#define FOO NULL
int i = FOO;
or
\#define FOO int i = NULL;
FOO
While providing appropriate tagging at different levels of the expansion, etc.
The included test case exercises these cases & does some basic validation (to
ensure we don't have macro expansion notes where we shouldn't, and do where we
should) - but doesn't go as far as to validate the source location/ranges
used in those notes and warnings.
After r150615, which tablegens the group of a diagnostic as an index into the *.inc file, all diagnostic *.inc
files depend on all other diagnostic *.td files, because a diagnostic group can be introduced at any of the diagnostic
*.td files.
Axel Naumann [Fri, 16 Mar 2012 10:40:17 +0000 (10:40 +0000)]
From Vassil Vassilev:
Enable incremental parsing by the Preprocessor,
where more code can be provided after an EOF.
It mainly prevents the tearing down of the topmost lexer.
To be used like this:
PP.enableIncrementalProcessing();
while (getMoreSource()) {
while (Parser.ParseTopLevelDecl(ADecl)) {...}
}
PP.enableIncrementalProcessing(false);
Richard Smith [Fri, 16 Mar 2012 06:12:59 +0000 (06:12 +0000)]
Fix Objective-C compilation-time performance regression introduced in r152608.
Reintroduce lazy name lookup table building, ensuring that the lazy building step
produces the same lookup table that would be built by the eager step.
Avoid building a lookup table for the translation unit outside C++, even in cases
where we can't recover the contents of the table from the declaration chain on
the translation unit, since we're not going to perform qualified lookup into it
anyway. Continue to support lazily building such lookup tables for now, though,
since ASTMerge uses them.
In my tests, this performs very similarly to ToT with r152608 backed out, for C,
Obj-C and C++, and does not suffer from PR10447.
Chad Rosier [Thu, 15 Mar 2012 22:31:42 +0000 (22:31 +0000)]
[frontend] Fix how the frontend handles -fno-inline. AFAIK clang now matches
the behavior of gcc with respect to the -fno-inline and -fno-inline-functions
flags.
Anna Zaks [Thu, 15 Mar 2012 21:13:02 +0000 (21:13 +0000)]
[analyzer] Allow checkers to supply call stack diagnostic hints for the
BugVisitor DiagnosticPieces.
When checkers create a DiagnosticPieceEvent, they can supply an extra
string, which will be concatenated with the call exit message for every
call on the stack between the diagnostic event and the final bug report.
(This is a simple version, which could be/will be further enhanced.)
For example, this is used in Malloc checker to produce the ",
which allocated memory" in the following example:
static char *malloc_wrapper() { // 2. Entered call from 'use'
return malloc(12); // 3. Memory is allocated
}
void use() {
char *v;
v = malloc_wrapper(); // 1. Calling 'malloc_wrappers'
// 4. Returning from 'malloc_wrapper', which allocated memory
} // 5. Memory is never released; potential
memory leak
[libclang] A couple of enhancements to c-index-test.
-When printing location avoid printing the filename if it is
same as the main file, not just if it has '.h' extension.
-Make sure we allocate enough bytes for storing as string a
huge line number.
[Sema] Introduce a data recursive evaluator specific to binary operators.
This allows us to handle extreme cases of chained binary operators without causing stack
overflow.
The binary operators that are handled with the data recursive evaluator are
comma, logical, or operators that have operands with integral or enumeration type.
Bill Wendling [Thu, 15 Mar 2012 09:27:30 +0000 (09:27 +0000)]
Add the object size checking support for a few other builtins.
The functions memccpy, strdup, strndup, strlcat, and strlcpy should also have
object size checking support. Of course, this is only good if the C library also
supports these functions.
<rdar://problem/10528974>
David Blaikie [Thu, 15 Mar 2012 05:09:31 +0000 (05:09 +0000)]
Unpluralize -Wfoo-conversions warnings for consistency.
Err on the side of brevity and rename (while providing aliases for the original
name) -Wbool-conversions, -Wint-conversions, and -Wvector-conversions for
consistency with constant, literal, string, and sign conversion warnings. And
name the diagnostic groups explicitly while I'm here rather than rewriting the
string in the groups and sema td files.
Curiously, vector-conversion is not under -Wconversion. Perhaps it should be.
Richard Smith [Thu, 15 Mar 2012 04:53:45 +0000 (04:53 +0000)]
Unrevert r152761 (reverted in r152772) with a fix for the issue which was
breaking bootstrap. No test yet: it's quite hard to tickle the failure case.
The specific testcase for this wouldn't be useful for testing anything more
general than a reintroduction of this precise bug in any case.
David Blaikie [Thu, 15 Mar 2012 04:50:32 +0000 (04:50 +0000)]
Reapply r152745 (reverted in 152765) now that compiler-rt is fixed.
Original commit message:
Provide -Wnull-conversion separately from -Wconversion.
Like GCC, provide a NULL conversion to non-pointer conversion as a separate
flag, on by default. GCC's flag is "conversion-null" which we provide for
cross compatibility, but in the interests of consistency (with
-Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called
-Wnull-conversion.
Patch by Lubos Lunak.
Review feedback by myself, Chandler Carruth, and Chad Rosier.
Richard Smith [Thu, 15 Mar 2012 00:41:48 +0000 (00:41 +0000)]
Minor optimization to constant evaluation: don't bother computing expr source
locations for diagnostics we're not going to emit, and don't track the subobject
designator outside C++11 (since we're not going to use it anyway).
This seems to give about a 0.5% speedup on 403.gcc/combine.c, but the results
were sufficiently noisy that I can't reject the null hypothesis.
Chad Rosier [Wed, 14 Mar 2012 23:32:11 +0000 (23:32 +0000)]
[frontend] Add support for disabling the "inline" keyword using
-fno-inline-functions.
This behaves much like -fno-inline in gcc, but based on a discussion with
Daniel it was decided that -fno-inline-functions should subsume -fno-inline.
Please speak up if you object. The -fno-inline flag remains ignored.
Final part of rdar://10972766