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.
David Blaikie [Mon, 30 Apr 2012 18:21:31 +0000 (18:21 +0000)]
Fix PR12378: provide conversion warnings on default args of function templates
Apparently we weren't checking default arguments when they were instantiated.
This adds the check, fixes the lack of instantiation caching (which seems like
it was mostly implemented but just missed the last step), and avoids
implementing non-dependent default args (for non-dependent parameter types) as
uninstantiated default arguments (so that we don't warn once for every
instantiation when it's not instantiation dependent).
Douglas Gregor [Mon, 30 Apr 2012 16:20:27 +0000 (16:20 +0000)]
Restore paren, bracket and brace counts in parser when
TentativeParsingAction is reverted, from Pasi Parviainen! Fixes
PR12480 / <rdar://problem/11341251>.
David Blaikie [Mon, 30 Apr 2012 02:36:29 +0000 (02:36 +0000)]
Remove the ref/value inconsistency in filter_decl_iterator.
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.
This change errs on the side of value, making op-> return T* and op* return
T&.
Richard Smith [Mon, 30 Apr 2012 00:16:51 +0000 (00:16 +0000)]
PR11926 + duplicates: Fix crash in -Wuninitialized when using a compiler like
g++4.7, which reuses stack space allocated for temporaries. CFGElement::getAs
returns a suitably-cast version of 'this'. Patch by Markus Trippelsdorf!
No test: this code has the same observable behavior as the old code when built
with most compilers, and the tests were already failing when built with a
compiler for which this produced a broken binary.
Richard Smith [Sun, 29 Apr 2012 07:31:09 +0000 (07:31 +0000)]
PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another
victim. Don't crash if we have a delay-parsed exception specification for a
class member which is invalid in a way which precludes building a FunctionDecl.
Richard Smith [Sun, 29 Apr 2012 06:32:34 +0000 (06:32 +0000)]
[class.copy]p23: Fix an assertion caused by incorrect argument numbering in a
diagnostic, add a test for this paragraph, and tighten up the diagnostic wording
a little.
Chris Lattner [Sat, 28 Apr 2012 16:12:17 +0000 (16:12 +0000)]
switch some uses of ExpectAndConsume(tok::semi to use ExpectAndConsumeSemi. This allows
us to improve this diagnostic (telling us to insert another ")":
t.c:2:19: error: expected ';' at end of declaration
int x = 4+(5-12));
^
;
to:
t.c:2:19: error: extraneous ')' before ';'
int x = 4+(5-12));
^
...telling us to remove the ")". This is PR12595. There are more uses of ExpectAndConsumeSemi
that could be switched over, but I don't hit them on a daily basis :)
Benjamin Kramer [Sat, 28 Apr 2012 10:00:42 +0000 (10:00 +0000)]
Rename isPODType (using the C++98 rules) into isCXX98PODType and make isPODType decide which one to use based on LangOptions.
- -Wc++98-compat depends on the c++98 definition
- Now __is_pod returns the right thing in c++11 and c++98 mode
- All changes to the type traits test are validated against g++ 4.7
objective-c modern translator: Correctly translate
nonfragile ivar access code when ivar type is a
locally defined struct/union type. // rdar://11323187
Douglas Gregor [Fri, 27 Apr 2012 22:30:01 +0000 (22:30 +0000)]
When @encode'ing a C++ class that has empty base classes, we can end
up with gaps when the class inherits from the same empty base class
more than once. Fixes <rdar://problem/11324167>.
Chad Rosier [Fri, 27 Apr 2012 19:51:11 +0000 (19:51 +0000)]
[driver] Don't try to set the deployment target when there is no bound
architecture; this was happening for tools such as lipo and dsymutil.
Also, if no -arch option has been specified, set the architecture based
on the TC default.
rdar://11329656
Richard Smith [Fri, 27 Apr 2012 19:33:05 +0000 (19:33 +0000)]
PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode.
We do not support IRGen for these, and get some parts of the semantic analysis
wrong.