Reid Kleckner [Thu, 12 Jun 2014 23:03:48 +0000 (23:03 +0000)]
Recover from missing 'typename' in sizeof(T::InnerType)
Summary:
'sizeof' is a UnaryExprOrTypeTrait, and it can contain either a type or
an expression. This change threads a RecoveryTSI parameter through the
layers between TransformUnaryExprOrTypeTrait the point at which we look
up the type. If lookup finds a single type result after instantiation,
we now build TypeSourceInfo for it just like a normal transformation
would.
This fixes the last error in the hello world ATL app that I've been
working with, and it now links and runs with clang. Please try it and
file bugs!
Nico Weber [Thu, 12 Jun 2014 21:15:10 +0000 (21:15 +0000)]
Tweak documentation.
1. Having "get started", "get involved", and "hacking" makes it hard to find
how to send patches, so add a link from "get involved" to "hacking".
2. Remove an almost 5 year old note on the test running meachanism changing
soon.
3. Let "hacking" link to the LLVM developer policy.
Objective-C ARC. Blocks that strongly capture themselves
to call themselves will get the warning:
"Capturing <itself> strongly in this block is likely to
lead to a retain cycle". Cut down on the amount of noise
by noticing that user at some point sets the captured variable
to null in order to release it (and break the cycle).
// rdar://16944538
Reid Kleckner [Thu, 12 Jun 2014 19:49:17 +0000 (19:49 +0000)]
MS ABI: Fix forming pointers to members of a base class
Previously we would calculate the inheritance model of a class when
requiring a pointer to member type of that class to be complete. The
inheritance model is used to figure out how many fields are used by the
member pointer.
However, once we require a pointer to member of a derived class type to
be complete, we can form pointers to members of bases without
calculating the inheritance model for those bases. This was causing
crashes on this simple test case:
struct A {
void f();
void f(int);
};
struct B : public A {};
void g() { void (B::*a)() = &B::f; }
Now we calculate the inheritance models of all base classes when
completing a member pointer type.
Thanks to David Blakie and Richard Smith for pointing out that we can retain the
-Wswitch coverage while avoiding the warning from GCC by pushing the unreachable
outside of the switch!
tools/clang/lib/Basic/DiagnosticIDs.cpp: In function ‘clang::DiagnosticIDs::Level toLevel(clang::diag::Severity)’:
tools/clang/lib/Basic/DiagnosticIDs.cpp:382:1: warning: control reaches end of non-void function [-Wreturn-type]
tools/clang/lib/Format/Format.cpp: In member function ‘virtual std::string clang::format::ParseErrorCategory::message(int) const’:
tools/clang/lib/Format/Format.cpp:282:1: warning: control reaches end of non-void function [-Wreturn-type]
Add a default cases that asserts that we handle the severity, parse error.
Richard Smith [Thu, 12 Jun 2014 00:32:32 +0000 (00:32 +0000)]
[modules] Add first-draft module maps for Clang. These don't cover everything
yet, but they're enough for a clean bootstrap (with a few local patches that
are yet to be committed).
Richard Smith [Thu, 12 Jun 2014 00:01:45 +0000 (00:01 +0000)]
PR19966: don't crash/assert when __underlying_type is applied to an incomplete
enumeration type. I've also filed a LWG issue pointing out that this should be
ill-formed.
Hans Wennborg [Wed, 11 Jun 2014 22:44:39 +0000 (22:44 +0000)]
Don't inherit dllimport to inline move assignment operators
Current MSVC versions don't have move assignment operators, so we
can't rely on them being available in the dll. If we have the
definition, we can just use that directly. This breaks pointer
equality, but should work fine otherwise.
When there is an MSVC version that supports move assignment,
we can key this off the -fmsc-ver option.
Aaron Ballman [Wed, 11 Jun 2014 19:11:24 +0000 (19:11 +0000)]
The automated server-side process isn't quite right yet, so this is a newly-generated attribute reference. Tanya is looking into the server process when she gets the chance.
Kaelyn Takata [Wed, 11 Jun 2014 18:33:46 +0000 (18:33 +0000)]
Add some comments to TypoCorrectionConsumer.
Also move the constructor for NamespaceSpecifierSet out of line to
improve the class' readability. I meant to do these two things while
cleaning up the previous TypoCorrectionConsumer changes and have them
folded into those changes.
Kaelyn Takata [Wed, 11 Jun 2014 18:07:08 +0000 (18:07 +0000)]
Sink SpecifierInfo into the only class that uses it.
SpecifierInfo is not used outside of NamespaceSpecifierSet except
indirectly through NamespaceSpecifierSet's iterator, so clean up the
code a bit by moving SpecifierInfo into NamespaceSpecifierSet. Also drop
SpecifierInfo's trivial yet verbose constructor since brace
initiialization is sufficient in the only two places the constructor was
being explicitly called.
Kaelyn Takata [Wed, 11 Jun 2014 18:07:05 +0000 (18:07 +0000)]
Make a couple of helper classes private to TypoCorrectionConsumer.
The SpecifierInfo and NamespaceSpecifierSet are now only used by
TypoCorrectionConsumer, so treat them as the implementation details of
TypoCorrectionConsumer that they are. Also make NamespaceSpecifierSet's
method names more style guide compliant.
Kaelyn Takata [Wed, 11 Jun 2014 18:07:01 +0000 (18:07 +0000)]
Move TypoCorrection filtering into the TypoCorrectionConsumer and make it incremental.
The only external/visible functional change that fell out of this
refactoring is that there was one less case where the typo caching
and/or counting didn't work properly. The result is that a test case
had to be moved from typo-correction.cpp to typo-correction-pt2.cpp
to avoid the hard-coded limit on per file/TU typo correction attempts.
Kaelyn Takata [Wed, 11 Jun 2014 18:06:56 +0000 (18:06 +0000)]
Move a few classes to be before TypoCorrectionConsumer.
This is in preparation for moving TypoCorrection filtering
into the TypoCorrectionConsumer, to separate out some of the purely
mechanical churn. It also makes some of the method names in
NamespaceSpecifierSet be more style guide compliant.
Objective-C. Patch to handle bridge attribute warnings
correctly when both NSAttributedString and
NSMutableAttributedString are specified on the same
CFStruct via different typedefs. // rdar://17238954
Bill Schmidt [Wed, 11 Jun 2014 15:48:46 +0000 (15:48 +0000)]
[PPC64LE] Fix vec_sld and vec_vsldoi for little endian
The vec_sld and vec_vsldoi interfaces perform a left-shift on vector
arguments for both big and little endian. However, because they rely
on the vec_perm interface which is endian-dependent, the permutation
vector needs to be reversed for LE to get the proper shift direction.
I've added some extra testing for these interfaces for LE in the
builtins-ppc-altivec.c.
David Majnemer [Wed, 11 Jun 2014 07:08:37 +0000 (07:08 +0000)]
MS ABI: Only class templates get complex nullptr pointer-to-member-functions
r210637 regressed CodeGenCXX/mangle-ms-templates-memptrs.cpp because it
did not believe that there is a distinction between class templates and
function templates.
Sadly, there is. Function templates should behave in a compatible
manner with MSVC.
David Majnemer [Wed, 11 Jun 2014 04:55:08 +0000 (04:55 +0000)]
MS ABI: Mangle null pointer-to-member-functions compatibly
Summary:
Previously, we would mangle nullptr pointer-to-member-functions in class
templates with a mangling we invented because contemporary versions of
MSVC would crash when trying to compile such code.
However, VS "14" can successfully compile these sorts of template
instantiations. This commit updates our mangling to be compatible with
theirs.
David Majnemer [Wed, 11 Jun 2014 04:08:55 +0000 (04:08 +0000)]
CodeGen: Correct linkage of thread_local for OS X
The backing store of thread local variables is internal for OS X and all
accesses must go through the thread wrapper.
However, individual TUs may have inlined through the thread wrapper.
To fix this, give the thread wrapper functions WeakAnyLinkage. This
prevents them from getting inlined into call-sites.
Kevin Qin [Wed, 11 Jun 2014 01:42:16 +0000 (01:42 +0000)]
[AArch64] Add default features for CPUs on AArch64 target.
For ARM target, we can use CRYPTO and CRC features if we select
cortex-a57 by '-mcpu', but for AArch64 target, it doesn't work
unless adding with '-mfpu=crypto-neon-fp-armv8'. To keep consistency
between front-end and back-end and get end-users more easier to use,
we'd better add default feature for CPUs on AArch64 target as well.
Richard Smith [Tue, 10 Jun 2014 23:43:44 +0000 (23:43 +0000)]
Teach __alignof__ to look through arrays before performing the
preferred-alignment transformations. Corrects alignof(T[]) to return
alignof(T) in all cases, as required by relevant standards.
Richard Smith [Tue, 10 Jun 2014 23:34:28 +0000 (23:34 +0000)]
Related to PR19992: when the GNU alignof-expression extension is applied to an
expression of array-of-unknown-bound type, don't try to complete the array
bound, and return the alignment of the element type rather than 1.
Reid Kleckner [Tue, 10 Jun 2014 23:29:48 +0000 (23:29 +0000)]
Recover from missing typenames on template args for MSVC compatibility
While matching a non-type template argument against a known template
type parameter we now modify the AST's TemplateArgumentLoc to assume the
user wrote typename. Under -fms-compatibility, we downgrade our
diagnostic from an error to an extwarn.
Bob Wilson [Tue, 10 Jun 2014 21:07:12 +0000 (21:07 +0000)]
Fix crash with x86_64-pc-win32-macho target. <rdar://problem/17235840>
The changes in r204978 broke win32-macho targets. There were checks added for
MSVC and Itanium environments as special cases, and win32-macho needs to be
treated the same way.
Objective-C IRGen. Patch to generate a weak symbol reference when
'super' dispatches a class method in category for OBJC_METACLASS.
This is when class is a weak_import class.
// rdar://16529125
Add detection of OS X relocatable SDK to compiler-rt as a lit.util function
Clang's lit cfg already detects the currently selected SDK via
"xcrun --show-sdk-path". The same thing should be done for compiler-rt tests,
to make them work on recent OS X versions. Instead of duplicating the detection
code, this patch extracts the detection function into a lit.util method.
Patch by Kuba Brecka (kuba.brecka@gmail.com),
reviewed at http://reviews.llvm.org/D4072
Hans Wennborg [Tue, 10 Jun 2014 00:55:51 +0000 (00:55 +0000)]
Improve checking for dynamic initializers of dllimport fields in template instantiation
We would previously assert if the initializer was dependent. I also think that
checking isConstantInitializer is more correct here than checkInitIsICE.
Richard Trieu [Mon, 9 Jun 2014 22:53:25 +0000 (22:53 +0000)]
Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context. The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.
Objective-C. Consider block pointer as NSObject as well as conforming to
'NSCopying' protocol when diagnosing block to ObjC pointer conversion.
// rdar://16739120
Fix line numbers for code inlined from __nodebug__ functions.
Instructions from __nodebug__ functions don't have file:line
information even when inlined into no-nodebug functions. As a result,
intrinsics (SSE and other) from <*intrin.h> clang headers _never_
have file:line information.
With this change, an instruction without !dbg metadata gets one from
the call instruction when inlined.
Bill Schmidt [Mon, 9 Jun 2014 03:31:47 +0000 (03:31 +0000)]
[PPC64LE] Implement little-endian semantics for vec_sums
The PowerPC vsumsws instruction, accessed via vec_sums, is defined
architecturally with a big-endian bias, in that the second input vector
and the result always reference big-endian element 3 (little-endian
element 0). For ease of porting, the programmer wants elements 3 in
both cases.
To provide this semantics, for little endian we generate a permute for
the second input vector prior to the vsumsws instruction, and generate
a permute for the result vector following the vsumsws instruction.
The correctness of this code is tested by the new sums.c test added in
a previous patch, as well as the modifications to
builtins-ppc-altivec.c in the present patch.