In StringLiteralParser::init(), fail gracefully if the string is
not as we expect; it may be due to racing issue of a file coming from PCH
changing after the PCH is loaded.
Richard Smith [Wed, 2 May 2012 22:22:32 +0000 (22:22 +0000)]
Revert most of r154844, which was disabled in r155975. Keep around the
refactorings in that revision, and some of the subsequent bugfixes, which
seem to be relevant even without delayed exception specification parsing.
Modern objective-c translation: Fixing couple of bugs
related to laying out ivar structs and accessing non-fragile-ivar
in more compilated cases. // rdar://11323187
Douglas Gregor [Wed, 2 May 2012 17:33:51 +0000 (17:33 +0000)]
Replace the StringSwitch in AttributeList::getKind() with a
TableGen-generated StringMatcher, for a 1.2% speedup in -fparse-only
time in <rdar://problem/11004361>. Thanks to Benjamin for pointing me
at StringMatcher!
David Blaikie [Wed, 2 May 2012 15:24:47 +0000 (15:24 +0000)]
Fix same line doxycomments so they comment the adjacent field.
Without the '<' prefix in the doxycomment these comments were incorrectly
attached to the proceeding comment on the next line, rather than the
preceeding one.
Benjamin Kramer [Wed, 2 May 2012 14:55:48 +0000 (14:55 +0000)]
Driver: Turn the default value for -fmath-errno into a proper target hook and disable it by default on more platforms.
For now -fno-math-errno is the default on BSD-derived platforms (Darwin,
DragonFlyBSD, FreeBSD, NetBSD, OpenBSD). If the default is not right for
your platform, please yell. I only verified the result with the default
compilers on Darwin and FreeBSD.
Douglas Gregor [Wed, 2 May 2012 14:34:16 +0000 (14:34 +0000)]
Replace a ConsumeAnyToken() call with ConsumeToken() when we know
we're looking at a normal token. Tiny positive impact -fsyntax-only
time for <rdar://problem/11004361>.
Douglas Gregor [Wed, 2 May 2012 14:24:30 +0000 (14:24 +0000)]
Replace the StringSwitch in AttributeList::getKind(const
IdentifierInfo *) with a static StringMap, improving -fsyntax-only
performance by 1% for the example in <rdar://problem/11004361>.
James Molloy [Wed, 2 May 2012 07:56:14 +0000 (07:56 +0000)]
Fix forwarding of -fpack-struct from driver to CC1, and add a test.
-fpack-struct's handling has changed in CC1 (one of only two flags that needed changing) because the driver treats "-fpack-struct" as a boolean flag, and CC1 (did) treat it as an option with a separated value.
This change causes -fpack-struct=X to be forwarded correctly to -fpack-struct=X instead of erroneously to "-fpack-struct X"
Richard Smith [Wed, 2 May 2012 01:29:43 +0000 (01:29 +0000)]
Disable our non-standard delayed parsing of exception specifications. Delaying
the parsing of such things appears to be a conforming extension, but it breaks
libstdc++4.7's std::pair.
Ted Kremenek [Wed, 2 May 2012 00:31:29 +0000 (00:31 +0000)]
Refine analyzer diagnostics by adding an expression "cone-of-influence" to reverse track interesting
values through interesting expressions. This allows us to map from interesting values in a caller
to interesting values in a caller, thus recovering some precision in diagnostics lost from IPA.
Richard Smith [Wed, 2 May 2012 00:30:48 +0000 (00:30 +0000)]
Unrevert r155951, reverted in r155962, with two changes:
* Work around build failures due to gcc 4.2 bugs.
* Remove BodyIndexer::TraverseCXXOperatorCallExpr, which was not being called
prior to this change, and whose presence disables a RecursiveASTVisitor
stack space optimization after this change.
Kaelyn Uhrain [Wed, 2 May 2012 00:11:40 +0000 (00:11 +0000)]
Try harder to recognize hidden tag type names in potential declarations instead
of giving unhelpful errors about undeclared identifers and missing semicolons.
Douglas Gregor [Tue, 1 May 2012 23:37:00 +0000 (23:37 +0000)]
Eliminate Sema::CompareMethodParamsInBaseAndSuper() entirely, by
folding its one check into the normal path for checking overridden
Objective-C methods. Good for another 3.6% speedup on the test case in
<rdar://problem/11004361>.
Douglas Gregor [Tue, 1 May 2012 23:07:34 +0000 (23:07 +0000)]
The semantic checking that verifies whether an Objective-C method
declared in a subclass has consistent parameter types with a method
having the same selector in a superclass performs a significant number
of lookups into the class hierarchy. In the example in
<rdar://problem/11004361>, we spend 4.7% of -fsyntax-only time in
these lookups.
Optimize away most of the calls to this routine
(Sema::CompareMethodParamsInBaseAndSuper) by first checking whether we
have ever seen *any* method with that selector (using the global
selector table). Since most selectors are unique, we can avoid the
cost of this name lookup in many cases, for a 3.3% speedup.
Richard Smith [Tue, 1 May 2012 21:58:31 +0000 (21:58 +0000)]
Fix RecursiveASTVisitor's data recursion to call the Traverse* functions if they
have been overridden in the derived class. Also, remove a non-functional
implementation of an incorrect optimization for ParenExprs.
Patrick Beard [Tue, 1 May 2012 21:47:19 +0000 (21:47 +0000)]
Clean up changes suggested by Douglas Gregor:
BuildObjCNumericLiteral() and BuildObjCBoxedExpr() now both using
PerformCopyInitialization() rather than PerformImplicitConversion(),
which suppresses errors.
In BuildObjCBoxedExpr(): no longer calling .getCanonicalType(),
ValueType->getAs() will remove the minimal amount of sugar.
Using ValueType->isBuiltinType() instead of isa<BuiltinType>(ValueType).
Anna Zaks [Tue, 1 May 2012 21:10:26 +0000 (21:10 +0000)]
[analyzer] Construct a SymExpr even when the constraint solver cannot
reason about the expression.
This essentially keeps more history about how symbolic values were
constructed. As an optimization, previous to this commit, we only kept
the history if one of the symbols was tainted, but it's valuable keep
the history around for other purposes as well: it allows us to avoid
constructing conjured symbols.
Specifically, we need to identify the value of ptr as
ElementRegion (result of pointer arithmetic) in the following code.
However, before this commit '(2-x)' evaluated to Unknown value, and as
the result, 'p + (2-x)' evaluated to Unknown value as well.
int *p = malloc(sizeof(int));
ptr = p + (2-x);
This change brings 2% slowdown on sqlite. Fixes radar://11329382.
John McCall [Tue, 1 May 2012 20:28:00 +0000 (20:28 +0000)]
During block layout, after padding up to the max field alignment,
the alignment might actually exceed the max field alignment; don't
assert in this case.
Douglas Gregor [Tue, 1 May 2012 20:23:02 +0000 (20:23 +0000)]
In C++11 mode, implement the C++11 semantics for
[basic.lookup.classref]p1 and p4, which concerns name lookup for
nested-name-specifiers and template names, respectively, in a member
access expression. C++98/03 forces us to look both in the scope of the
object and in the current scope, then compare the results. C++11 just
takes the result from the scope of the object, if something is
found. Fixes <rdar://problem/11328502>.
Chad Rosier [Tue, 1 May 2012 18:11:51 +0000 (18:11 +0000)]
Get rid of storelv4si builtin as it can be expressed directly. This is general
goodness because it provides opportunites to cleanup things. For example,
John McCall [Tue, 1 May 2012 17:32:20 +0000 (17:32 +0000)]
Restructure some of the member-pointer tests, implicitly
removing some that were added without a triple (and moving
their tests into files that appropriately test multiple
architectures).
John McCall [Tue, 1 May 2012 06:13:13 +0000 (06:13 +0000)]
Abstract the emission of global destructors into ABI-specific code
and only consider using __cxa_atexit in the Itanium logic. The
default logic is to use atexit().
Emit "guarded" initializers in Microsoft mode unconditionally.
This is definitely not correct, but it's closer to correct than
just not emitting the initializer.
David Blaikie [Tue, 1 May 2012 06:05:57 +0000 (06:05 +0000)]
PR12710 - broken default argument handling for templates.
I broke this in r155838 by not actually instantiating non-dependent default arg
expressions. The motivation for that change was to avoid producing duplicate
conversion warnings for such default args (we produce them once when we parse
the template - there's no need to produce them at each instantiation) but
without actually instantiating the default arg, things break in weird ways.
Technically, I think we could still get the right diagnostic experience without
the bugs if we instantiated the non-dependent args (for non-dependent params
only) immediately, rather than lazily. But I'm not sure if such a refactoring/
change would be desirable so here's the conservative fix for now.
Ted Kremenek [Tue, 1 May 2012 05:28:27 +0000 (05:28 +0000)]
Teach RetainCountchecker about IORegistryEntrySearchCFProperty returning retained objects. I know there is an SDK enhancement request for this to have the cf_returns_retained annotation, so this is just a stop gap.
John McCall [Tue, 1 May 2012 05:23:51 +0000 (05:23 +0000)]
Refactor the C++ ABI code a little bit to take advantage of
what I'm going to treat as basically universal properties of
array-cookie code. Implement MS array cookies on top of that.
Based on a patch by Timur Iskhodzhanov!
John McCall [Tue, 1 May 2012 02:33:44 +0000 (02:33 +0000)]
When mangling a synthetic function declaration, we might not have
type-source information for its parameters. Don't crash when
mangling them in the MS C++ ABI. Patch by Timur Iskhodzhanov!
David Blaikie [Tue, 1 May 2012 00:48:43 +0000 (00:48 +0000)]
Remove ref/value inconsistency in redecl_iterator.
Similar to r155808 - this mistake has been made in a few iterators.
Based on Chandler Carruth's feedback to r155808 I added an implicit conversion
to Decl* to ease adoption/usage. Useful for the pointer comparison, but not the
dyn_cast (due to template argument deduction causing the conversion not to be
used) - there for future convenience, though. This idiom (op T* for iterators)
seems to be fairly idiomatic within the LLVM codebase & I'll likely add it as I
fix up the other iterators here.
John McCall [Tue, 1 May 2012 00:38:49 +0000 (00:38 +0000)]
My first effort to do this more subtly failed, so elaborately
test for an invalid declaration at every single place in the
constant evaluator that's about to request a struct layout.
Richard Smith [Mon, 30 Apr 2012 23:33:33 +0000 (23:33 +0000)]
Remove -Wc++98-compat warning for an outrageously-rare circumstance of 'this'
being used in an exception specification in a way which isn't otherwise
ill-formed in C++98: this warning also incorrectly triggered on uses of 'this'
inside thread-safety attributes, and the mechanism required to tell these cases
apart is more complex than can be justified by the (minimal) value of this part
of -Wc++98-compat.
When going through references to check if the function returns the address
of a local variable, make sure we don't infinitely recurse when the
reference binds to itself.
e.g:
int* func() {
int& i = i; // assign non-exist variable to a reference which has same name.
return &i; // return pointer
}
modern objective-c translator. named aggregate types
defined inside the objc class belong to class's
decl. scope. This is to conform to objective-c
rules. // rdar://11351299
Store the source range of a CXXOperatorCallExpr in the Expr object instead of
calculating it recursively.
boost::assign::tuple_list_of uses the trick of chaining call operator expressions in order to declare a "list of tuples", e.g:
std::vector<tuple> v = boost::assign::tuple_list_of(1, "foo")(2, "bar")(3, "qqq");
Due to CXXOperatorCallExpr calculating its source range recursively we would get
significant slowdowns with a large number of chained call operator expressions and the
potential for stack overflow.