Manuel Klimek [Mon, 5 May 2014 09:58:03 +0000 (09:58 +0000)]
Fix crash when resolving branch conditions for temporary destructor condition blocks.
Document and simplify ResolveCondition.
1. Introduce a temporary special case for temporary desctructors when resolving
the branch condition - in an upcoming patch, alexmc will change temporary
destructor conditions to not run through this logic, in which case we can remove
this (marked as FIXME); this currently fixes a crash.
2. Simplify ResolveCondition; while documenting the function, I noticed that it
always returns the last statement - either that statement is the condition
itself (in which case the condition was returned anyway), or the rightmost
leaf is returned; for correctness, the rightmost leaf must be evaluated anyway
(which the CFG does in the last statement), thus we can just return the last
statement in that case, too. Added an assert to verify the invariant.
Alp Toker [Mon, 5 May 2014 06:22:21 +0000 (06:22 +0000)]
Add speculative clang-interpreter test
Let's see how far this gets on the build servers. The application requires
native JIT and uses the C standard library, but hopefully we can get this
tested on at least some configurations.
Taking a lead from the clang-format tests, we'll just expect the executable to
get picked up from the build output path for now.
Ben Langmuir [Mon, 5 May 2014 05:31:33 +0000 (05:31 +0000)]
Make module self-import an error
Ideally, importing Foo.a from Foo.b would "do the right thing", but
until it does, this patch makes it an error rather than allow it to
silently be ignored.
Windows on ARM uses AAPCS, but has some deviations. wchar_t remains an unsigned
short on WoA, which does not conform to AAPCS. Ensure that wchar_t is defined
accordingly.
Nico Weber [Sat, 3 May 2014 22:07:35 +0000 (22:07 +0000)]
Minor cleanups, no behavior change.
* Fixes a "return" that was indented at the same level as the continuation
from the previous line
* Wrap several lines to 80 columns
* Remove an if check that was always true
* Move a variable declaration slightly closer to its use
[leaks] The PDFileEntry nodes in the FilesMade FoldingSet contain
a std::vector that allocates on the heap. As a consequence, we have to
run all of their destructors when tearing down the set, not just
deallocate the memory blobs.
[leaks] Re-shuffle code such that we don't create a basic block for
initializing an array unless we need it. Specifically, position the
creation of a new basic block after we've checked all of the cases that
bypass the need for it.
Fixes another leak in test/CodeGen* found by LSan.
David Majnemer [Sat, 3 May 2014 02:23:35 +0000 (02:23 +0000)]
CodeGen: Cleanup ABIArgInfo
ABIArgInfo was pretty hard to grok, it had data members with names like
"BoolData0" and "UIntData". Constructors with lots of bool arguments.
Reusing the same data member for multiple purposes.
It was also wasteful with memory, this new layout is 8 bytes smaller.
Nick Lewycky [Sat, 3 May 2014 00:41:18 +0000 (00:41 +0000)]
Rewrite NRVO determination. Track NRVO candidates on the parser Scope and apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal.
Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith.
Reid Kleckner [Sat, 3 May 2014 00:33:28 +0000 (00:33 +0000)]
MS ABI x64: Pass small objects with dtors but no copy ctors directly
Passing objects directly (in registers or memory) creates a second copy
of the object in the callee. The callee always destroys its copy, but
we also have to destroy any temporary created in the caller. In other
words, copy elision of these kinds of objects is impossible.
Objects larger than 8 bytes with non-trivial dtors and trivial copy
ctors are still passed indirectly, and we can still elide copies of
them.
[leaks] Fix a leak of a basic block when we successfully fold a switch
condition to a constant and emit only the relevant statement. In that
case, we were previously creating the epilog jump destination, a cleanup
scope, and emitting any condition variable into it. Instead, we can emit
the condition variable (if we have one) into the cleanup scope used for
the entire folded case sequence. We avoid creating a jump dest, a basic
block, and an extra cleanup scope. Win!
[leaks] Parse the schema file every time we try to verify the XML. Yes,
this is wasteful, blah blah, but this is a test utility only. It turns
out that without doing this, libxml2 will always leak a bunch of the XML
data, and that is causing failures with LSan. This is also quite a bit
simpler and I don't think it is slow enough to really be a show stopper.
If someone yells about the runtime of c-index-test, we can do other
things to try to mitigate it, but the current strategy wasn't working
well.
[leaks] Fix a leak recently introduced to the pragma handling. This
whole code would be better with std::unique_ptr managing the lifetimes
of the handlers, but I wanted to make a targeted fix to the leaks first.
With this change, all of the Clang preprocessor tests are leak free with
LSan.
Aaron Ballman [Fri, 2 May 2014 13:35:42 +0000 (13:35 +0000)]
Updated the attribute tablegen emitter for variadic arguments to emit a range accessor in addition to the iterators. Updated code using iterators to use range-based for loops.
Alp Toker [Fri, 2 May 2014 03:43:30 +0000 (03:43 +0000)]
Factor TargetInfo pointer/DelayInitialization bool pair out of Preprocessor ctor
The Preprocessor::Initialize() function already offers a clear interface to
achieve this, further reducing the confusing number of states a newly
constructed preprocessor can have.
Reid Kleckner [Fri, 2 May 2014 01:14:59 +0000 (01:14 +0000)]
Win64: Use ConvertType instead of checking the MS inheritance
dependent-type-member-pointer.cpp is failing on a win64 bot because
-fms-extensions is not enabled. Use ConvertType rather than relying on
the inheritance attributes. It's less code, but probably slower.
Reid Kleckner [Fri, 2 May 2014 00:51:20 +0000 (00:51 +0000)]
Win64: Pass member pointers larger than 8 bytes by reference
The Win64 ABI docs on MSDN say that arguments bigger than 8 bytes are
passed by reference. Prior to this change, we were only applying this
logic to RecordType arguments. This affects both the Itanium and
Microsoft C++ ABIs.
Reid Kleckner [Fri, 2 May 2014 00:05:16 +0000 (00:05 +0000)]
MS ABI: Fix logic bug in member pointer null test code
This code is trying to test if the pointer is *not* null. Therefore we
should use 'or' instead of 'and' to combine the results of 'icmp ne'.
This logic is consistent with the general member pointer comparison code
in EmitMemberPointerComparison.
Richard Smith [Thu, 1 May 2014 23:24:24 +0000 (23:24 +0000)]
Bitrig's standard C++ standard library changed from libstdc++ to libc++.
Also, it uses libc++abi and needs pthread. While there, fix the libc++
include path. Patch by Patrick Wildt!
Kaelyn Takata [Thu, 1 May 2014 21:15:24 +0000 (21:15 +0000)]
When sorting overload candidates, sort arity mismatches in ascending
order by the number of missing or extra parameters. This is useful if
there are more than a few overload candidates with arity mismatches,
particularly in the presence of -fshow-overloads=best.
Lubos Lunak [Thu, 1 May 2014 21:11:57 +0000 (21:11 +0000)]
write a line marker right before adding included file
Enclosing the original #include directive inside #if 0 adds lines,
so warning/errors messages would have the line number off in
"In file included from <file>:<line>:", so add line marker to fix this.
The test can now catch all cases:
- no removal of the 'no-integrated-as' flag
- bogus removal of the flag, like when the remove_if was not followed by an erase
David Blaikie [Thu, 1 May 2014 18:13:24 +0000 (18:13 +0000)]
Fix debug-info-alias test to add CHECK to some lines that were missing it.
To simplify source location offsets, this test uses line directives to
force particular lines of interest to have known line numbers so that
adjustments before/after those points don't require updates to the CHECK
lines.
David Majnemer [Thu, 1 May 2014 17:50:17 +0000 (17:50 +0000)]
AST: Mangle reference temporaries reliably
Summary:
Previously, we would generate a single name for all reference
temporaries and allow LLVM to rename them for us. Instead, number the
reference temporaries as we build them in Sema.
Reid Kleckner [Thu, 1 May 2014 16:50:23 +0000 (16:50 +0000)]
MSVCCompat: Don't produce an invalid AST when accepting void pseudo-dtors
We accept 'void *p; p->~void();' for MSVC compatibility since r148682.
However, we were returning ExprError, rather than producing an AST,
despite only diagnosing it with a warning. CodeGen noticed that the
template function specialization had an invalid AST, and therefore
didn't generate code for it. This change makes us produce an AST with a
void pseudo-dtor call.
Aaron Ballman [Thu, 1 May 2014 15:21:03 +0000 (15:21 +0000)]
Fixing a FIXME -- no longer using std::memcpy, since that would fail for non-trivial types. Replaced with std::copy. No functional changes intended since all uses of this functionality either use pointers or integers.
Lubos Lunak [Thu, 1 May 2014 13:50:44 +0000 (13:50 +0000)]
do not use "1" for line marker for the main file
"1" means entering a new file (from a different one), but the main
file is not included from anything (and this would e.g. confuse -Wunused-macros
to not report unused macros in the main file, see pr15610, or also see pr18948).
The line marker is still useful e.g. if the resulting file is renamed or used
via a pipe.
Lubos Lunak [Thu, 1 May 2014 12:45:08 +0000 (12:45 +0000)]
write a line marker right before adding included file
Enclosing the original #include directive inside #if 0 adds lines,
so warning/errors messages would have the line number off in
"In file included from <file>:<line>:", so add line marker to fix this.
Ben Langmuir [Thu, 1 May 2014 03:33:36 +0000 (03:33 +0000)]
Avoid a potential race between stat() and open() of ASTFile
We need to open an ASTFile while checking its expected size and
modification time, or another clang instance can modify the file between
the stat() and the open().
Reid Kleckner [Thu, 1 May 2014 03:07:18 +0000 (03:07 +0000)]
MS ABI x64: Don't destroy arguments twice on x64
We were destroying them in the callee, and then again in the caller. We
should use an EH-only cleanup and disable it at the point of the call
for win64, even though we don't use inalloca.
Richard Smith [Thu, 1 May 2014 00:35:04 +0000 (00:35 +0000)]
Make typo-correction of inheriting constructors work a bit better. Limit
correction to direct base class members, and recover properly after we apply
such a correction.
Dmitri Gribenko [Wed, 30 Apr 2014 21:54:30 +0000 (21:54 +0000)]
Comment parsing: remove HTML attribute validation
Since the community says that a blacklist is not good enough, and I don't have
enough time now to implement a proper whitelist, let's just remove the
attribute validation.
But, nevertheless, we can still communicate in the generated XML if our parser
found an issue with the HTML. But this bit is best-effort and is specifically
called out in the schema as such.