Chandler Carruth [Mon, 20 Feb 2012 07:35:45 +0000 (07:35 +0000)]
Add 3dNOW intrinsic header to x86intrin.h, conditioned on __3dNOW__ to
match the behavior of GCC. Also add a test for these intrinsics, which
apparently have *zero* tests. =[ Not surprisingly, Clang crashed when
compiling these.
Fix the bug in CodeGen where we failed to bitcast the argument type to
x86mmx prior to calling the LLVM intrinsic. This fixes an assert on the
new 3dnow-builtins.c test.
This is one issue impacting the efforts to get Clang to emulate the
Microsoft intrinsics headers -- 3dnow intrinsics are implictitly made
available there.
Chandler Carruth [Sun, 19 Feb 2012 23:09:50 +0000 (23:09 +0000)]
Make the regular expressions in this test more narrow to ensure we're
actually matching the write substrings, and stop looking for a leading
'/' to try and finish fixing darwin and other hosts.
Rafael Espindola [Sun, 19 Feb 2012 01:38:32 +0000 (01:38 +0000)]
Implement a -gcc-toolchain command line option that does the same as
configure's --with-gcc-toolchain. The configure option is now just a default
value for the command line one.
Richard Smith [Sat, 18 Feb 2012 22:04:06 +0000 (22:04 +0000)]
Implement constant expression support for __real__ and __imag__ on lvalue
complex numbers. Treat complex numbers as arrays of the corresponding component
type, in order to make std::complex behave properly if implemented in terms of
_Complex T.
Apparently libstdc++'s std::complex is implemented this way, and we were
rejecting a member like this:
constexpr double real() { return __real__ val; }
because it was marked constexpr but unable to produce a constant expression.
Ted Kremenek [Sat, 18 Feb 2012 22:02:57 +0000 (22:02 +0000)]
Fix crash in analyzer diagnostic generation involving subexpressions of OpaqueValueExpr not appearing in the ParentMap. Fixes <rdar://problem/10797980>.
Ted Kremenek [Sat, 18 Feb 2012 20:53:30 +0000 (20:53 +0000)]
Adopt ExprEngine and checkers to ObjC property refactoring. Everything was working, but now diagnostics are aware of message expressions implied by uses of properties. Fixes <rdar://problem/9241180>.
Douglas Gregor [Sat, 18 Feb 2012 09:37:24 +0000 (09:37 +0000)]
Rewrite variable capture within lambda expressions and blocks,
eliminating a bunch of redundant code and properly modeling how the
captures of outside blocks/lambdas affect the types seen by inner
captures.
This new scheme makes two passes over the capturing scope stack. The
first pass goes up the stack (from innermost to outermost), assessing
whether the capture looks feasible and stopping when it either hits
the scope where the variable is declared or when it finds an existing
capture. The second pass then walks down the stack (from outermost to
innermost), capturing the variable at each step and updating the
captured type and the type that an expression referring to that
captured variable would see. It also checks type-specific
restrictions, such as the inability to capture an array within a
block. Note that only the first odr-use of each
variable needs to do the full walk; subsequent uses will find the
capture immediately, so multiple walks need not occur.
The same routine that builds the captures can also compute the type of
the captures without signaling errors and without actually performing
the capture. This functionality is used to determine the type of
declaration references as well as implementing the weird decltype((x))
rule within lambda expressions.
The capture code now explicitly takes sides in the debate over C++
core issue 1249, which concerns the type of captures within nested
lambdas. We opt to use the more permissive, more useful definition
implemented by GCC rather than the one implemented by EDG.
Douglas Gregor [Sat, 18 Feb 2012 05:51:20 +0000 (05:51 +0000)]
Unify our computation of the type of a captured reference to a
variable; it was previously duplicated, and one of the copies failed
to account for outer non-mutable lambda captures.
Richard Smith [Sat, 18 Feb 2012 04:58:18 +0000 (04:58 +0000)]
Fix a problem in the GCC testsuite, exposed by r150557. Compound literals
are represented as prvalues in C++; don't be fooled into thinking they're
global lvalues.
Richard Smith [Sat, 18 Feb 2012 04:13:32 +0000 (04:13 +0000)]
Diagnose uses of deleted destructors and inaccessible defaulted destructors.
We had two separate issues here: firstly, varions functions were assuming that
they did not need to perform semantic checks on trivial destructors (this is
not true in C++11, where a trivial destructor can nonetheless be private or
deleted), and a bunch of DiagnoseUseOfDecl calls were missing for uses of
destructors.
Richard Smith [Sat, 18 Feb 2012 02:02:13 +0000 (02:02 +0000)]
Initial refactoring of 'ShouldDeleteSpecialMember', in preparation for providing
decent diagnostics. Finish the work of combining all the 'ShouldDelete'
functions into one. In unifying the code, fix a minor bug where an anonymous
union with a deleted default constructor as a member of a union wasn't being
considered as making the outer union's default constructor deleted.
Eric Christopher [Sat, 18 Feb 2012 00:50:08 +0000 (00:50 +0000)]
Remove UpdateCompletedType from the debug info emission. We now
emit less than complete types on purpose on occasion and so
our caches aren't useful for this kind of lazy emitting.
Anna Zaks [Fri, 17 Feb 2012 22:35:31 +0000 (22:35 +0000)]
[analyzer] Fix another false positive in the Malloc Checker, by making
it aware of CString APIs that return the input parameter.
Malloc Checker needs to know how the 'strcpy' function is
evaluated. Introduce the dependency on CStringChecker for that.
CStringChecker knows all about these APIs.
Anna Zaks [Fri, 17 Feb 2012 22:35:26 +0000 (22:35 +0000)]
[analyzer] Generalize function name checking in CString checker.
(Ex: It was not treating __inline_strcpy as strcpy. Will add tests that
rely on this later on.)
Sebastian Redl [Fri, 17 Feb 2012 08:42:25 +0000 (08:42 +0000)]
Basic code generation support for std::initializer_list.
We now generate temporary arrays to back std::initializer_list objects
initialized with braces. The initializer_list is then made to point at
the array. We support both ptr+size and start+end forms, although
the latter is untested.
Array lifetime is correct for temporary std::initializer_lists (e.g.
call arguments) and local variables. It is untested for new expressions
and member initializers.
Things left to do:
Massively increase the amount of testing. I need to write tests for
start+end init lists, temporary objects created as a side effect of
initializing init list objects, new expressions, member initialization,
creation of temporary objects (e.g. std::vector) for initializer lists,
and probably more.
Get lifetime "right" for member initializers and new expressions. Not
that either are very useful.
Implement list-initialization of array new expressions.
Richard Smith [Fri, 17 Feb 2012 07:31:37 +0000 (07:31 +0000)]
The clang half of r150794: after the construction of a global or static const
variable ends, if the variable has a trivial destructor and no mutable
subobjects then emit an llvm.invariant.start call for it. globalopt knows to
make the variable const when evaluating this.
Richard Smith [Fri, 17 Feb 2012 04:54:50 +0000 (04:54 +0000)]
When performing IRGen on a global, emit it as a constant if:
1) It has a const-qualified type, and
2) It has no mutable members, and
3) It has no dynamic initialization, and
4) It has trivial destruction.
Remove the unnecessary requirement that the type be POD. This allows us to
mark all constexpr objects with no mutable members as 'constant'.
Douglas Gregor [Fri, 17 Feb 2012 03:49:44 +0000 (03:49 +0000)]
Disambiguate between C++11 lambda expressions and C99 array
designators in the parser. In the worst case, this disambiguation
requires tentative parsing just past the closing ']', but for most
cases we'll be able to tell by looking ahead just one token (without
going into the heavyweight tentative parsing machinery).
Richard Smith [Fri, 17 Feb 2012 03:35:37 +0000 (03:35 +0000)]
Make sure all remaining parts of the constant evaluator are aware that an array
can be represented by an LValue, and use that to simplify the code a little.
John McCall [Fri, 17 Feb 2012 03:33:10 +0000 (03:33 +0000)]
Whether an argument is required (in contrast with being an
optional argument passed through the variadic ellipsis)
potentially affects how we need to lower it. Propagate
this information down to the various getFunctionInfo(...)
overloads on CodeGenTypes. Furthermore, rename those
overloads to clarify their distinct purposes, and make
sure we're calling the right one in the right place.
This has a nice side-effect of making it easier to construct
a function type, since the 'variadic' bit is no longer
separable.
This shouldn't really change anything for our existing
platforms, with one minor exception --- we should now call
variadic ObjC methods with the ... in the "right place"
(see the test case), which I guess matters for anyone
running GNUStep on MIPS. Mostly it's just a substantial
clean-up.
Douglas Gregor [Fri, 17 Feb 2012 03:02:34 +0000 (03:02 +0000)]
Rework the Sema/AST/IRgen dance for the lambda closure type's
conversion to function pointer. Rather than having IRgen synthesize
the body of this function, we instead introduce a static member
function "__invoke" with the same signature as the lambda's
operator() in the AST. Sema then generates a body for the conversion
to function pointer which simply returns the address of __invoke. This
approach makes it easier to evaluate a call to the conversion function
as a constant, makes the linkage of the __invoke function follow the
normal rules for member functions, and may make life easier down the
road if we ever want to constexpr'ify some of lambdas.
Note that IR generation is responsible for filling in the body of
__invoke (Sema just adds a dummy body), because the body can't
generally be expressed in C++.
Richard Smith [Fri, 17 Feb 2012 01:35:32 +0000 (01:35 +0000)]
Reject continue/break statements within members of local functions nested within
loop and switch statements, by teaching Scope that a function scope never has
a continue/break parent for the purposes of control flow. Remove the hack in
block and lambda expressions which worked around this by pretending that such
expressions were continue/break scopes.
Remove Scope::ControlParent, since it's unused.
In passing, teach default statements to recover properly from a missing ';', and
add a fixit for same to both default and case labels (the latter already
recovered correctly).
Richard Smith [Fri, 17 Feb 2012 00:44:16 +0000 (00:44 +0000)]
PR12012: Fix a regression in r150419 where we would try (and fail) to
zero-initialize class types with virtual bases when constant-evaluating an
initializer.
Eric Christopher [Thu, 16 Feb 2012 22:54:45 +0000 (22:54 +0000)]
Reapply r150631:
"Add a completed/incomplete type difference. This allows us to have
partial types for contexts and forward decls while allowing us to
complete types later on for debug purposes.
This piggy-backs on the metadata replacement and rauw changes
for temporary nodes and takes advantage of the incremental
support I added in earlier. This allows us to, if we decide,
to limit adding methods and variables to structures in order
to limit the amount of debug information output into a .o file.
The caching is a bit complicated though so any thoughts on
untangling that are welcome."
with a fix:
- Remove all RAUW during type construction by adding stub versions
of types that we later complete.
and some TODOs:
- Add an RAUW cache for forward declared types so that we can replace
them at the end of compilation.
- Remove the code that updates on completed types because we no
longer need to have that happen. We emit incomplete types on
purpose and only want to know when we want to complete them.
Kaelyn Uhrain [Thu, 16 Feb 2012 22:40:59 +0000 (22:40 +0000)]
Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration.
Don't try to typo-correct a method redeclaration to declarations not in
the current record as it could lead to infinite recursion if CorrectTypo
finds more than one correction candidate in a parent record.
Douglas Gregor [Thu, 16 Feb 2012 21:53:36 +0000 (21:53 +0000)]
Improve recovery for lambda expressions that have 'mutable' or a
trailing return type but not a '()'. Recover by inserting the
parentheses. Thanks to Xeo on IRC for the example.
Douglas Gregor [Thu, 16 Feb 2012 21:36:18 +0000 (21:36 +0000)]
Lambda closure types are always considered to be like "local" classes,
even if they are not within a function scope. Teach template
instantiation to treat them as such, and make sure that we have a
local instantiation scope when instantiating default arguments and
static data members.
Ted Kremenek [Thu, 16 Feb 2012 20:48:04 +0000 (20:48 +0000)]
Revert "Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change."
Ted Kremenek [Thu, 16 Feb 2012 20:19:30 +0000 (20:19 +0000)]
Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change.
Douglas Gregor [Thu, 16 Feb 2012 18:19:22 +0000 (18:19 +0000)]
In Objective-C++, allow the keyword 'class' to be used as a property
name for dot syntax, e.g., NSObject.class or foo.class. For other
C++-keywords-as-method-names, use message send syntax. Fixes
<rdar://problem/10794452>.