Douglas Gregor [Wed, 6 Feb 2013 18:08:37 +0000 (18:08 +0000)]
Eliminate a race condition with the global module index.
Essentially, a module file on disk could change size between the time
we stat() it and the time we open it, and we need to be robust against
such a problem.
Manuel Klimek [Wed, 6 Feb 2013 16:40:56 +0000 (16:40 +0000)]
Fix handling of comments in macros.
We now correctly format:
// Written as a macro, it is reformatted from:
#define foo(a) \
do { \
/* Initialize num to zero. */ \
int num = 10; \
/* This line ensures a is never zero. */ \
int i = a == 0 ? 1 : a; \
i = num / i; /* This division is OK. */ \
return i; \
} while (false)
Daniel Jasper [Wed, 6 Feb 2013 14:22:40 +0000 (14:22 +0000)]
Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.
With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.
Manuel Klimek [Wed, 6 Feb 2013 10:33:21 +0000 (10:33 +0000)]
Adds a convenience function selectFirst to simplify matching.
A very common use case is to search for the first occurrence of
a certain node that is a descendant of another node. In that
case, selectFirst significantly simplifies the code at the client side.
Daniel Jasper [Wed, 6 Feb 2013 10:05:46 +0000 (10:05 +0000)]
Handle nested ObjC calls.
Properly handle annotation contexts while calculating extra information
for each token. This enable nested ObjC calls and thus solves (most of)
llvm.org/PR15164. E.g., we can now format:
Nico Weber [Wed, 6 Feb 2013 06:20:11 +0000 (06:20 +0000)]
Formatter: No space after & and * in front of ObjC message expressions.
1. let determineStarAmp() check of unary operators before checking for
"is next '['". That check was added in r173150, and the test from that
revision passes either way.
2. change determineStarAmp() to categorize '*' and '&' after '=' as unary
operator.
3. don't let parseSquare() overwrite the type of a '*' or '&' before the start
of an objc message expression if has the role of unary operator.
Anna Zaks [Wed, 6 Feb 2013 00:01:14 +0000 (00:01 +0000)]
[analyzer]Revert part of r161511; suppresses leak false positives in C++
This is a "quick fix".
The underlining issue is that when a const pointer to a struct is passed
into a function, we do not invalidate the pointer fields. This results
in false positives that are common in C++ (since copy constructors are
prevalent). (Silences two llvm false positives.)
Ted Kremenek [Tue, 5 Feb 2013 22:00:19 +0000 (22:00 +0000)]
Change subexpressions to be visited in the CFG from left-to-right.
This is a more natural order of evaluation, and it is very important
for visualization in the static analyzer. Within Xcode, the arrows
will not jump from right to left, which looks very visually jarring.
It also provides a more natural location for dataflow-based diagnostics.
Along the way, we found a case in the analyzer diagnostics where we
needed to indicate that a variable was "captured" by a block.
-fsyntax-only timings on sqlite3.c show no visible performance change,
although this is just one test case.
Jordan Rose [Tue, 5 Feb 2013 17:31:34 +0000 (17:31 +0000)]
[analyzer] Add a doc describing the internals of RegionStore.
This is a text file with Markdown-ish formatting because we haven't decided
where analyzer internal documents should go, but it's probably better to
have this in source control than sitting on my local drive forever.
[frontend] Don't put a PCH/PTH filename into the set of includes in the preprocessor options;
since only one of them is allowed in command-line, process them separately.
Otherwise, if more than one is specified in the command-line, one is processed normally
and the others are going to be treated and included as header files.
Daniel Jasper [Tue, 5 Feb 2013 10:07:47 +0000 (10:07 +0000)]
Initial support for formatting ObjC method declarations/calls.
We can now format stuff like:
- (void)doSomethingWith:(GTMFoo *)theFoo
rect:(NSRect)theRect
interval:(float)theInterval {
[myObject doFooWith:arg1 //
name:arg2
error:arg3];
}
This seems to fix everything mentioned in llvm.org/PR14939.
Daniel Jasper [Tue, 5 Feb 2013 09:34:14 +0000 (09:34 +0000)]
Fix formatting regression introduced by r174307.
In preprocessor definitions, we would not parse all the tokens and thus
not annotate them anymore. This led to a wrong formatting of comments
in google style:
Manuel Klimek [Mon, 4 Feb 2013 10:59:20 +0000 (10:59 +0000)]
Implements the convenience matcher findAll.
We found that findAll has been implemented incorrectly multiple times
by various people using the matchers. To prevent further wasted
development effort, it makes sense to add it as convenience matcher
implemented as eachOf(m, forEachDescendant(m)).
This patch also updates the docs with the new matchers.
Manuel Klimek [Mon, 4 Feb 2013 09:42:38 +0000 (09:42 +0000)]
Add an eachOf matcher.
eachOf gives closure on the forEach and forEachDescendant matchers.
Before, it was impossible to implement a findAll matcher, as matching
the node or any of its descendants was not expressible (since anyOf
only triggers the first match).
Daniel Jasper [Mon, 4 Feb 2013 07:34:48 +0000 (07:34 +0000)]
Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are
high that they represent logically separate concepts. Otherwise,
the author could just have just a single literal (possible split
over multiple lines).
So, we can now nicely format things like:
cout << "somepacket = {\n"
<< " val a = " << ValueA << "\n"
<< " val b = " << ValueB << "\n"
<< "}";
Daniel Jasper [Mon, 4 Feb 2013 07:21:18 +0000 (07:21 +0000)]
Restructuring of token annotation for formatting.
This combines several changes:
* Calculation token type (e.g. for * and &) in the AnnotatingParser.
* Calculate the scope binding strength in the AnnotatingParser.
* Let <> and [] scopes bind stronger than () and {} scopes.
* Add minimal debugging output.
Benjamin Kramer [Sun, 3 Feb 2013 19:59:25 +0000 (19:59 +0000)]
CodeGen: Implement hint values for dynamic_cast as described in the Itanium C++ ABI.
This can yield dramatic speedups of dynamic_cast for simple inheritance trees,
at least with libsupc++. Neither libcxxabi nor libcxxrt make use of this
hint currently, it was never implemented because clang didn't support it.
There was some concern about the number of class hierarchy walks this change
introduces. If it turns out to be an issue we can add caching either at the cast
pair level or even deeper, but we also do a lot of walks in Sema so this
codepath is probably fairly optimized already.
NAKAMURA Takumi [Sun, 3 Feb 2013 12:52:54 +0000 (12:52 +0000)]
clang/test/CodeGenCXX/debug-info-class.cpp: Tweak to unbreak test for a few targets.
- Relax a expression for arm-gnueabi.
- Exclude msvc to limit target triplets to add limited a few targets.
Feel free to remove actions if guys thought they redundant.
Jordan Rose [Sat, 2 Feb 2013 05:15:53 +0000 (05:15 +0000)]
Revert "[analyzer] Model trivial copy/move ctors with an aggregate bind."
...again. The problem has not been fixed and our internal buildbot is still
getting hangs.
This reverts r174212, originally applied in r173951, then reverted in r174069.
Will not re-apply until the entire project analyzes successfully on my
local machine.
Richard Smith [Sat, 2 Feb 2013 02:14:45 +0000 (02:14 +0000)]
PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".
For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".
For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.
David Blaikie [Sat, 2 Feb 2013 00:34:26 +0000 (00:34 +0000)]
Generalize DebugInfo tests by avoiding explicit metadata numbers
This addresses several (not all) debug info tests that use explicit metadata
numbers. Wherever the same number appeared more than once in a test I used
a named match to ensure the same number appeared in all those cases (this may
still be overly constraining test cases as they may not have actually cared
about that relationship). For one-off numbers I just replaced them with an
unnamed regex.
This may underconstrain poorly written test cases that were interested in
checking that certain metadata nodes were related but didn't actually match
on all the related nodes numbers.
Anna Zaks [Sat, 2 Feb 2013 00:30:04 +0000 (00:30 +0000)]
[analyzer] Always inline functions with bodies generated by BodyFarm.
Inlining these functions is essential for correctness. We often have
cases where we do not inline calls. For example, the shallow mode and
when reanalyzing previously inlined ObjC methods as top level.
Nick Lewycky [Sat, 2 Feb 2013 00:25:55 +0000 (00:25 +0000)]
This patch makes "&Cls::purevfn" not an odr use. This isn't what the standard
says, but that's a defect (to be filed). "Cls::purevfn()" is still an odr use.
Also fixes a bug that caused us to not mark the function referenced just
because we didn't want to mark it odr used.
Douglas Gregor [Fri, 1 Feb 2013 23:45:03 +0000 (23:45 +0000)]
Merge "special" types from different modules in the AST reader.
Different modules may have different views of the various "special"
types in the AST, such as the redefinition type for "id". Merge those
types rather than only considering the redefinition types for the
first AST file loaded.
Jordan Rose [Fri, 1 Feb 2013 19:49:57 +0000 (19:49 +0000)]
[analyzer] Reuse a LazyCompoundVal if its type matches the new region.
This allows us to keep from chaining LazyCompoundVals in cases like this:
CGRect r = CGRectMake(0, 0, 640, 480);
CGRect r2 = r;
CGRect r3 = r2;
Previously we only made this optimization if the struct did not begin with
an aggregate member, to make sure that we weren't picking up an LCV for
the first field of the struct. But since LazyCompoundVals are typed, we can
make that inference directly by comparing types.
This is a pure optimization; the test changes are to guard against possible
future regressions.
David Blaikie [Fri, 1 Feb 2013 19:09:49 +0000 (19:09 +0000)]
Fix exception handling line table problems introduced by r173593
r173593 made us a little too eager to associate all code at the end of a
function with the user-written 'return' line. This caused problems with
breakpoints as they'd be set in exception handling code preceeding the
actual non-exception return handling code, leading to the breakpoint never
being hit in non-exceptional execution.
This change restores the pre-r173593 exception handling line information where
the cleanup code is associated with the '}' not the return line.