[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.
Let stddef.h respect __need_{wchar_t, size_t, NULL, ptrdiff_t, wint_t}.
glibc expects that stddef.h only defines a single thing if either of these
defines is set. For example, before this change, a C file containing
#include <stdlib.h>
int ptrdiff_t = 0;
would compile with gcc but not with clang. Now it compiles with clang too.
This also fixes PR12997, where older versions of the Linux headers would define
NULL incorrectly, and glibc would define __need_NULL and expect stddef.h to
redefine NULL with the correct definition.
Richard Smith [Wed, 30 Apr 2014 02:24:17 +0000 (02:24 +0000)]
Defer loading any pending update records until we've finished deserializing.
This fixes a bug where an update record causes us to load an entity that refers
to an entity we've not finished loading yet, resulting in badness.
Rafael Espindola [Wed, 30 Apr 2014 02:22:09 +0000 (02:22 +0000)]
Drop non-cfi assembly support from clang.
After this patch clang will ignore -fdwarf2-cfi-asm and -ffno-dwarf2-cfi-asm and
always print assembly that uses cfi directives.
In llvm, MC itself supports cfi since the end of 2010 (support started
in r119972, is reported in the 2.9 release notes).
In binutils the support has been around for much longer. It looks like
support started to be added in May 2003. It is available in 2.15
(31-Aug-2011, 2.14 is from 12-Jun-2003).
[PCH/Modules] Don't tie TargetOptions::LinkerVersion to a module/PCH, it's a driver only thing and doesn't affect any language/preprocessor/etc. semantics.
Jordan Rose [Tue, 29 Apr 2014 17:08:17 +0000 (17:08 +0000)]
[analyzer] Improve test from r207486.
The constructor that comes right before a variable declaration in the CFG might
not be the initialization of that variable. Previously, we just checked that
the variable's initializer expression was different from the construction
expression, but forgot to see whether the variable had an initializer expression
at all.
Jordan Rose [Tue, 29 Apr 2014 17:08:12 +0000 (17:08 +0000)]
[analyzer] Don't assert when combining using .* on a temporary.
While we don't model pointer-to-member operators yet (neither .* nor ->*),
CallAndMessageChecker still checks to make sure the 'this' object is not
null or undefined first. However, it also expects that the object should
always have a valid MemRegion, something that's generally important elsewhere
in the analyzer as well. Ensure this is true ahead of time, just like we do
for member access.
Ben Langmuir [Tue, 29 Apr 2014 16:25:26 +0000 (16:25 +0000)]
Reapply r207477 and r207479 without cyclic dependency
Fixed by moving ProcessWarningOptions from Frontend into Basic. All of
the dependencies for ProcessWarningOptions were already in Basic, so
this was a small change.
David Majnemer [Tue, 29 Apr 2014 07:32:26 +0000 (07:32 +0000)]
AST: Fix visibility calculation for VarTemplateSpecializationDecl
It is possible that a variable template specialization might not have a
VisibilityAttr attached to it while the template that it specializes
does, in fact, have one.
Adrian Prantl [Tue, 29 Apr 2014 01:07:59 +0000 (01:07 +0000)]
Debug info: Improve line table for functions with cleanups an early exit
and no return expr at the end of the function.
The "function has only simple returns" check in FinishFunction tests
whether the number of simple return exprs equals the number of return
exprs, but so far a fallthrough at the end of a function was not counted
as a return, which would result in cleanup code being associated with the
wrong source line.