Manuel Klimek [Fri, 12 Apr 2013 14:13:36 +0000 (14:13 +0000)]
Revamps structural error detection / handling.
Previously we'd only detect structural errors on the very first level.
This leads to incorrectly balanced braces not being discovered, and thus
incorrect indentation.
This change fixes the problem by:
- changing the parser to use an error state that can be detected
anywhere inside the productions, for example if we get an eof on
SOME_MACRO({ some block <eof>
- previously we'd never break lines when we discovered a structural
error; now we break even in the case of a structural error if there
are two unwrapped lines within the same line; thus,
void f() { while (true) { g(); y(); } }
will still be re-formatted, even if there's missing braces somewhere
in the file
- still exclude macro definitions from generating structural error;
macro definitions are inbalanced snippets
Daniel Jasper [Fri, 12 Apr 2013 10:12:01 +0000 (10:12 +0000)]
Provide better emacs integration.
The new emacs integration is simpler, does not save the current file
before reformatting and ensures that emacs does not scroll as a result
of formatting.
Also explicitly set the style in clang-format tests to make them more
robust.
Jordan Rose [Fri, 12 Apr 2013 00:44:01 +0000 (00:44 +0000)]
[analyzer] Don't emit extra context arrow after returning from an inlined call.
In this code
int getZero() {
return 0;
}
void test() {
int problem = 1 / getZero(); // expected-warning {{Division by zero}}
}
we generate these arrows:
+-----------------+
| v
int problem = 1 / getZero();
^ |
+---+
where the top one represents the control flow up to the first call, and the
bottom one represents the flow to the division.* It turns out, however, that
we were generating the top arrow twice, as if attempting to "set up context"
after we had already returned from the call. This resulted in poor
highlighting in Xcode.
* Arguably the best location for the division is the '/', but that's a
different problem.
Douglas Gregor [Fri, 12 Apr 2013 00:18:53 +0000 (00:18 +0000)]
<rdar://problem/13615607> Include SDK version information in the module hash.
This is a Darwin-SDK-specific hash criteria used to identify a
particular SDK without having to hash the contents of all of its
headers. If other platforms have such versioned files, we should add
those checks here.
Struct-path aware TBAA: uniformize scalar tag and path tag.
For struct-path aware TBAA, we used to use scalar type node as the scalar tag,
which has an incompatible format with the struct path tag. We now use the same
format: base type, access type and offset.
We also uniformize the scalar type node and the struct type node: name, a list
of pairs (offset + pointer to MDNode). For scalar type, we have a single pair.
These are to make implementaiton of aliasing rules easier.
[ms-cxxabi] Implement member pointer emission and dereferencing
Summary:
Handles all inheritance models for both data and function member
pointers.
Also implements isZeroInitializable() and refactors some of the null
member pointer code.
MSVC supports converting member pointers through virtual bases, which
clang does not (yet?) support. Implementing that extension is covered
by http://llvm.org/15713
Daniel Jasper [Thu, 11 Apr 2013 14:29:13 +0000 (14:29 +0000)]
Change clang-format's affinity for breaking after return types.
Function declarations are now broken with the following preferences:
1) break amongst arguments.
2) break after return type.
3) break after (.
4) break before after nested name specifiers.
Options #2 or #3 are preferred over #1 only if a substantial number of
lines can be saved by that.
Anna Zaks [Wed, 10 Apr 2013 21:42:06 +0000 (21:42 +0000)]
[analyzer] When reporting a leak in RetainCount checker due to an early exit from init, step into init.
The heuristic here (proposed by Jordan) is that, usually, if a leak is due to an early exit from init, the allocation site will be
a call to alloc. Note that in other cases init resets self to [super init], which becomes the allocation site of the object.
Chad Rosier [Wed, 10 Apr 2013 16:33:34 +0000 (16:33 +0000)]
[ms-inline asm] Add a few test cases that were regressed by r179115. That
commit was reverted in r179120, but I do plan on reapplying with a fix shortly.
Part of rdar://13611297
Richard Smith [Wed, 10 Apr 2013 06:11:48 +0000 (06:11 +0000)]
Add support for computing the exception specification for an inheriting
constructor. This isn't quite perfect (as usual, we don't handle default
arguments correctly yet, and we don't deal with copy/move constructors for
arguments correctly either, but this will be fixed when we implement core issue
1351.
This completes our support for inheriting constructors.
Michael Ilseman [Wed, 10 Apr 2013 01:04:18 +0000 (01:04 +0000)]
Improve the diagnostics of the number-reading preprocessor directives.
The GNU line marker directive was sharing code with the #line directive, but some of the warnings/errors were reporting as #line directive diagnostics in both cases.
Richard Trieu [Tue, 9 Apr 2013 22:06:27 +0000 (22:06 +0000)]
Remove outdated run lines from tests.
These run lines originally tested that the fix-its were properly applied.
Originally, the fixits were attached to warnings and were applied by -fixit.
Now, the fixits are attached to notes, so nothing happens. These run lines
still manage to pass since Clang will produce an empty output which gets piped
back to Clang. Then Clang produces no error on an empty input.
isVirtual - matches CXXMethodDecl nodes for virtual methods
isOverride - matches CXXMethodDecl nodes for methods that override virtual methods from a base class.
Objective-C: This patch fixes a none-issuance of warning
when result type of protocol property and getter method
differ by fixing a more serious problem. When a forward
protocol declaration comes between its definition and
its use in class protocol list, the forward protocol
ast was being used in building the protocol list.
// rdar://12522752
Daniel Jasper [Tue, 9 Apr 2013 15:23:04 +0000 (15:23 +0000)]
Improvements to clang-format integrations.
This adds an emacs editor integration (thanks to Ami Fischman). Also
pulls out the style into a variable for the vi integration and just
uses clang-formats defaults style in clang-format-diff.py.
One more follow-up to r179082 - parse PIC/PIE arguments even on platfroms that force default PIC (like Darwin x86-64), otherwise specifying -fPIC will produce bogus unused argument warning
Jordan Rose [Tue, 9 Apr 2013 02:30:33 +0000 (02:30 +0000)]
[analyzer] Replace isIntegerType() with isIntegerOrEnumerationType().
Previously, the analyzer used isIntegerType() everywhere, which uses the C
definition of "integer". The C++ predicate with the same behavior is
isIntegerOrUnscopedEnumerationType().
However, the analyzer is /really/ using this to ask if it's some sort of
"integrally representable" type, i.e. it should include C++11 scoped
enumerations as well. hasIntegerRepresentation() sounds like the right
predicate, but that includes vectors, which the analyzer represents by its
elements.
This commit audits all uses of isIntegerType() and replaces them with the
general isIntegerOrEnumerationType(), except in some specific cases where
it makes sense to exclude scoped enumerations, or any enumerations. These
cases now use isIntegerOrUnscopedEnumerationType() and getAs<BuiltinType>()
plus BuiltinType::isInteger().
isIntegerType() is hereby banned in the analyzer - lib/StaticAnalysis and
include/clang/StaticAnalysis. :-)
Fixes real assertion failures. PR15703 / <rdar://problem/12350701>
John McCall [Mon, 8 Apr 2013 23:27:49 +0000 (23:27 +0000)]
Don't copy just to capture a strong block pointer under ARC.
It turns out that the optimizer can't eliminate this without extra
information, for which there's a separate bug.
Douglas Gregor [Mon, 8 Apr 2013 23:24:07 +0000 (23:24 +0000)]
<rdar://problem/13584715> Converted constant expressions are expected to have integral values.
We were assuming that any expression used as a converted constant
expression would either not have a folded constant value or would be
an integer, which is not the case for some ill-formed constant
expressions. Because converted constant expressions are only used
where integral values are expected, we can simply treat this as an
error path. If that ever changes, we'll need to widen the interface of
Sema::CheckConvertedConstantExpression() anyway.
Douglas Gregor [Mon, 8 Apr 2013 23:11:25 +0000 (23:11 +0000)]
<rdar://problem/13540899> Collect using directives from all of the semantic contexts not represented by scopes.
This fixes a regression I introduced in r178136, where we would not
consider the using directives from the semantic declaration contexts
that aren't represented by the lexical scopes (Scope) when performing
unqualified name lookup. This lead to horribly funny diagnostics like
"no identifier named 'foo'; did you mean 'foo'?".
Douglas Gregor [Mon, 8 Apr 2013 21:13:13 +0000 (21:13 +0000)]
<rdar://problem/13559825> Further reduce template instantiation depth down to 256, since we're blowing the stack for a trivial "factorial" class template.