Dmitri Gribenko [Thu, 7 Feb 2013 19:09:22 +0000 (19:09 +0000)]
libclang: reduce CXString abuse
ContainerUSR is not really a CXString, but it should own the underlying memory
buffer. Thus, it is better to change the type to std::string. This will not
introduce extra copying overhead, since the workaround that is being removed
was already making a copy.
Tim Northover [Thu, 7 Feb 2013 15:11:48 +0000 (15:11 +0000)]
Only check for volatile memcpys in test.
AArch64 handles aggFct's return struct slightly differently, leading
to an extra memcpy. This test is fortunately only concerned about
volatile copies, so we can modify the grep text to filter it.
Tim Northover [Thu, 7 Feb 2013 15:11:40 +0000 (15:11 +0000)]
XFAIL test that's inappropriate for AArch64 ABI
Only some ABIs require the "signext" attribute on parameters. On most
platforms, however, it's a useful test so it's best not to limit it to some
random arbitrary platform.
Manuel Klimek [Thu, 7 Feb 2013 12:42:10 +0000 (12:42 +0000)]
Implements equalsNode for Decl and Stmt.
This is a powerful tool when doing iterative refined matches,
where another match is started inside the match callback of the first
one; this allows for example to find out whether the node was in
the condition or body of its parent if-statement.
Richard Smith [Thu, 7 Feb 2013 03:37:08 +0000 (03:37 +0000)]
Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).
1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.
2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.
Richard Smith [Thu, 7 Feb 2013 03:30:24 +0000 (03:30 +0000)]
Simplify FindExternalVisibleDeclsByName by making it return a bool indicating
if it found any decls, rather than returning a list of found decls. This
removes a returning-ArrayRef-to-deleted-storage bug from
MultiplexExternalSemaSource (in code not exercised by any of the clang
binaries), reduces the work required in the found-no-decls case with PCH, and
importantly removes the need for DeclContext::lookup to be reentrant.
-Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly.
Summary:
-Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly:
1. In actual unreachable code, but not immediately on a fall-through execution
path "fallthrough annotation does not directly precede switch label" is better;
2. After default: in a switch with covered enum cases. Actually, these shouldn't
be treated as unreachable code for our purpose.
Richard Smith [Thu, 7 Feb 2013 01:35:44 +0000 (01:35 +0000)]
AST dumping: indicate the previous declaration for a redeclaration, and
indicate the semantic DC if it's not the lexical DC. In passing, correct
the ascii-art child marker for a child of a FriendDecl.
Douglas Gregor [Thu, 7 Feb 2013 00:21:12 +0000 (00:21 +0000)]
Introduce -fmodules-ignore-macro=NNN to ignore a macro when building/loading modules.
The use of this flag enables a modules optimization where a given set
of macros can be labeled as "ignored" by the modules
system. Definitions of those macros will be completely ignored when
building the module hash and will be stripped when actually building
modules. The overall effect is that this flag can be used to
drastically reduce the number of
Eventually, we'll want modules to tell us what set of macros they
respond to (the "configuration macros"), and anything not in that set
will be excluded. However, that requires a lot of per-module
information that must be accurate, whereas this option can be used
more readily.
Douglas Gregor [Wed, 6 Feb 2013 22:40:31 +0000 (22:40 +0000)]
Detect when we end up trying to load conflicting module files.
This can happen when one abuses precompiled headers by passing more -D
options when using a precompiled hedaer than when it was built. This
is intentionally permitted by precompiled headers (and is exploited by
some build environments), but causes problems for modules.
First part of <rdar://problem/13165109>, detecting when something when
horribly wrong.
Manuel Klimek [Wed, 6 Feb 2013 20:36:22 +0000 (20:36 +0000)]
Cleanup of ASTMatcher macros and adding support for overloaded matchers.
This is in preparation for adding other overloaded matchers. This change
alone is a net win in LOC.
I went through all matchers and looked whether we could now encode them
as macro, or simplify them with the matcher atoms that were not
available before.
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.