Richard Smith [Thu, 5 Dec 2013 08:30:59 +0000 (08:30 +0000)]
PR17983: Fix crasher bug in C++1y mode when performing a non-global array
delete on a class which has no array cookie and has no class-specific operator
new.
Richard Smith [Thu, 5 Dec 2013 07:51:02 +0000 (07:51 +0000)]
Implement DR482: namespace members can be redeclared with a qualified name
within their namespace, and such a redeclaration isn't required to be a
definition any more.
Update DR status page to say Clang 3.4 instead of SVN and add new Clang 3.5
category (but keep Clang 3.4 yellow for now).
[objc] If an interface has no initializer marked as designated and introduces at least one new initializer,
don't assume that it inherits the designated initializers from the super class.
If the assumption was wrong because a new initializer was a designated one that was not marked as such,
we will emit misleading warnings for subclasses of the interface.
Richard Smith [Thu, 5 Dec 2013 04:30:04 +0000 (04:30 +0000)]
Per [dcl.meaning]p1, a name in an inline namespace can be redeclared using a
name from the enclosing namespace set if the name is specified as a
qualified-id.
Reid Kleckner [Thu, 5 Dec 2013 01:41:37 +0000 (01:41 +0000)]
Fix non-MSVC build error in ASTContext::getAdjustedType
Use FunctionTypeUnwrapper like we do in AttributedType to try to keep
some sugar. We can actually do one better here in the future by
avoiding the AdjustedType node altogether when no sugar would be lost.
Faisal Vali [Thu, 5 Dec 2013 01:40:41 +0000 (01:40 +0000)]
Fix init-captures for generic lambdas.
For an init capture, process the initialization expression
right away. For lambda init-captures such as the following:
const int x = 10;
auto L = [i = x+1](int a) {
return [j = x+2,
&k = x](char b) { };
};
keep in mind that each lambda init-capture has to have:
- its initialization expression executed in the context
of the enclosing/parent decl-context.
- but the variable itself has to be 'injected' into the
decl-context of its lambda's call-operator (which has
not yet been created).
Each init-expression is a full-expression that has to get
Sema-analyzed (for capturing etc.) before its lambda's
call-operator's decl-context, scope & scopeinfo are pushed on their
respective stacks. Thus if any variable is odr-used in the init-capture
it will correctly get captured in the enclosing lambda, if one exists.
The init-variables above are created later once the lambdascope and
call-operators decl-context is pushed onto its respective stack.
Since the lambda init-capture's initializer expression occurs in the
context of the enclosing function or lambda, therefore we can not wait
till a lambda scope has been pushed on before deciding whether the
variable needs to be captured. We also need to process all
lvalue-to-rvalue conversions and discarded-value conversions,
so that we can avoid capturing certain constant variables.
For e.g.,
void test() {
const int x = 10;
auto L = [&z = x](char a) { <-- don't capture by the current lambda
return [y = x](int i) { <-- don't capture by enclosing lambda
return y;
}
};
If x was not const, the second use would require 'L' to capture, and
that would be an error.
Make sure TranformLambdaExpr is also aware of this.
Patch approved by Richard (Thanks!!)
http://llvm-reviews.chandlerc.com/D2092
Once this happens, we would believe that D with a nested namespace
specifier of A was a variable that was being declared. We would go on
to complain that there was an extraneous 'template <>' on their variable
declaration.
Crashes would happen when 'A' gets defined as 'enum class A {}' as
various asserts would fire.
Instead, we should skip up until the semicolon if we see that we are in
the middle of a definition and the current token is a ':'
Reid Kleckner [Thu, 5 Dec 2013 01:23:43 +0000 (01:23 +0000)]
Add an AdjustedType sugar node for adjusting calling conventions
Summary:
In general, this type node can be used to represent any type adjustment
that occurs implicitly without losing type sugar. The immediate use of
this is to adjust the calling conventions of member function pointer
types without breaking template instantiation.
Mark Lacey [Thu, 5 Dec 2013 01:23:01 +0000 (01:23 +0000)]
Simplify the constructor to CodeGenABITypes.
The CodeGenOptions are not used for ABI type selection, so we will just
create one with the default constructor (there is a FloatABI option in
CodeGenOptions that is passed on to LLVM, but not used in Clang for LLVM
IR type generation).
We can use the DiagnosticsEngine on the ASTContext rather than making a
client pass one in explicitly.
Richard Smith [Thu, 5 Dec 2013 00:58:33 +0000 (00:58 +0000)]
Reject template-ids containing literal-operator-ids that have a dependent
nested-name-specifier, rather than crashing. (In fact, reject all
literal-operator-ids that have a non-namespace nested-name-specifier). The
grammar doesn't allow these in some cases, and in other cases does allow them
but instantiation will always fail.
Aaron Ballman [Wed, 4 Dec 2013 23:23:19 +0000 (23:23 +0000)]
Giving a Subjects list to DllExport, which allows the removal of some custom semantic handling. The same cannot be done for DllImport, and so comments were left explaining why.
Faisal Vali [Wed, 4 Dec 2013 22:43:08 +0000 (22:43 +0000)]
Fix for PR18052 - Lambdas within NSDMI's and default arguments in Nested classes.
Clang currently croaks on the following:
struct X1 {
struct X2 {
int L = ([] (int i) { return i; })(2);
};
};
asserting that the containing lexical context of the lambda is not Sema's cur context, when pushing the lambda's decl context on.
This occurs because (prior to this patch) getContainingDC always returns the non-nested class for functions at class scope (even for inline member functions of nested classes (to account for delayed parsing of their bodies)). The patch addresses this by having getContainingDC always return the lexical DC for a lambda's call operator.
Link to the bug: http://llvm.org/bugs/show_bug.cgi?id=18052
Link to Richard Smith's feedback on phabricator: http://llvm-reviews.chandlerc.com/D2331
Aaron Ballman [Wed, 4 Dec 2013 22:23:43 +0000 (22:23 +0000)]
The MSP430Interrupt attribute does have a sema handler (it's in TargetAttributesSema). Added a FIXME about the attribute being nameless when it really does have a valid name, and a comment explaining why we're using the name instead of the attribute kind.
Aaron Ballman [Wed, 4 Dec 2013 22:02:33 +0000 (22:02 +0000)]
Getting rid of some hard-coded strings. No functional changes intended, though some test cases needed to be updated for attribute names becoming quoted.
ObjectiveC - Introducing objc_bridge_related attribute
which specifies couple of (optional) method selectors
for bridging a CFobject to or from an ObjectiveC
object. This is wip. // rdsr://15499111
John Thompson [Wed, 4 Dec 2013 20:19:30 +0000 (20:19 +0000)]
Enea Zaffanella's fix for the PPCallbacks Elif callback, with a slight re-org, and an update of the new PPCallbacks test (soon to be moved to clang from extra), rather the unittest.
Reid Kleckner [Wed, 4 Dec 2013 19:23:12 +0000 (19:23 +0000)]
[ms-cxxabi] Construct and destroy call arguments in the correct order
Summary:
MSVC destroys arguments in the callee from left to right. Because C++
objects have to be destroyed in the reverse order of construction, Clang
has to construct arguments from right to left and destroy arguments from
left to right.
This patch fixes the ordering by reversing the order of evaluation of
all call arguments under the MS C++ ABI.
Aaron Ballman [Wed, 4 Dec 2013 15:32:26 +0000 (15:32 +0000)]
When parsing ignored attribute arguments, presuming the first argument is an unresolved identifier the same way that we do for unknown arguments. This resolves PR18075, where we regressed the handling of OpenBSD's bounded attribute.
Leave constructor initializer lists on one line in styles with no column limit.
Summary:
Allow tryFitMultipleLinesInOne join unwrapped lines when
ContinuationIndenter::mustBreak doesn't agree. But don't merge any lines, that
are separate in the input.
[SystemZ] Fix handling of pass-by-pointer arguments
I'd misunderstood getIndirect() to mean that the argument should be passed
as a pointer at the ABI level, with the ByVal argument choosing caller-copy
semantics over no-caller-copy (callee-copy-on-write) semantics. But
getIndirect(x) actually means that x is passed by pointer at the IR
level but (at least on all other targets I looked at) directly at the
ABI level. getIndirect(x, false) selects a pointer to a caller-made
copy, which is what SystemZ was aiming for.
This fixes a miscompilation of c-index-test. Structure arguments were being
passed by pointer, but no copy was being made, so a write in the callee
stomped over a caller's local variable.
David Majnemer [Wed, 4 Dec 2013 09:01:55 +0000 (09:01 +0000)]
Sema: Propagate the mangling number into instantiations
We would lose track of the mangling number assigned to the original
declaration which would cause us to create manglings that didn't match
the Itanium C++ specification.
e.g. Two static fields with the same name inside of a function template
would receive the same mangling with LLVM fixing up the second field so
they wouldn't collide. This would create an incompatibility with other
compilers following the Itanium ABI.
I've confirmed that the new mangling is identical to the ones generated
by icc and gcc.
N.B. This was uncovered while working on Microsoft mangler.
Faisal Vali [Wed, 4 Dec 2013 03:51:14 +0000 (03:51 +0000)]
Fix PR17637: incorrect calculation of template parameter depth
In delayed template parsing mode, adjust the template depth counter for each template parameter list associated with an out of line member template specialization.
[objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.
A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.
[objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.
[objc] Emit a warning when the implementation of a designated initializer does not chain to
an init method that is a designated initializer for the superclass.
[objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get the
designated initializers of an interface.
If the interface declaration does not have methods marked as designated
initializers then the interface inherits the designated initializers of
its super class.
Daniel Jasper [Tue, 3 Dec 2013 20:30:36 +0000 (20:30 +0000)]
Fix corner case in module-based layering warning.
Before, there SourceManager would not return a FileEntry for a
SourceLocation of a macro expansion (if the header name itself is
defined in a macro). We'd then fallback to assume that the module
currently being built is the including module. However, in this case we
are actually interested in the spelling location of the filename loc in
order to derive the including module.
Hans Wennborg [Tue, 3 Dec 2013 18:02:51 +0000 (18:02 +0000)]
CMake: enable building the clang-format vs plugin
This makes it possible to build the clang-format vs plugin from the cmake build.
It is a hack, as it shells out to "devenv" to actually build it, but it's hidden
away in a corner behind a flag, and it provides a convenient way of building the
plug-in from the command-line together with the rest of clang.
Alp Toker [Tue, 3 Dec 2013 06:13:01 +0000 (06:13 +0000)]
Emit an extension warning when changing system header tokens
clang converts keywords to identifiers for compatibility with various system
headers such as GNU libc.
Implement a -Wkeyword-compat extension warning to diagnose those cases. The
warning is on by default but will generally be ignored in system headers. It
can however be enabled globally to aid standards conformance testing.
This also changes the __uptr keyword avoidance from r195710 to no longer
special-case system headers, bringing it in line with other similar workarounds
in clang.
Implementation returns bool for symmetry with token annotation functions.
Some examples:
warning: keyword '__is_pod' will be treated as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_pod
warning: keyword '__uptr' will be treated as an identifier here [-Wkeyword-compat]
union w *__uptr;
Hao Liu [Tue, 3 Dec 2013 05:58:49 +0000 (05:58 +0000)]
AArch64: add missing ACLE intrinsics mapping to general arithmetic operation from VFP instructions.
E.g. float64x1_t vadd_f64(float64x1_t a, float64x1_t b) -> FADD Dd, Dn, Dm.
Hao Liu [Tue, 3 Dec 2013 05:35:17 +0000 (05:35 +0000)]
revert r196152.
This is a duplicate implementation.
E.g. this patch defines:
float64_t vabd_f64(float64_t a, float64_t b)
But there is already a similar intrinsic "vabdd_f64" with the same types.
Also, this intrinsic will be conflicted to the vector type intrinsic as following(Which is implemented by me and will be committed to trunk):
float64x1_t vabd_f64(float64x1_t a, float64x1_t b).
Two functions shouldn't have a same name in arm_neon.h.
According to ARM ACLE document, such vabd_f64 with float64_t is not existing.
So I revert this commit.
Dmitri Gribenko [Tue, 3 Dec 2013 00:48:09 +0000 (00:48 +0000)]
MS inline asm: When LLVM called back to Clang to parse a name and do name
lookup, if parsing failed, we did not restore the lexer state properly, and
eventually crashed. This change ensures that we always consume all the tokens
from the new token stream we started to parse the name from inline asm.
Aaron Ballman [Mon, 2 Dec 2013 22:38:33 +0000 (22:38 +0000)]
Refactored the work group-related attributes to use a template, which reduces the amount of duplicate code in the handler. No functional change intended.
Aaron Ballman [Mon, 2 Dec 2013 21:09:08 +0000 (21:09 +0000)]
The CUDA device attribute doesn't need custom logic to check the number of attribute arguments (the common attribute handler already does this). Switching to use the simple attribute handler. No functional change intended.