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.
Ben Langmuir [Tue, 29 Apr 2014 00:36:53 +0000 (00:36 +0000)]
Check -Werror options during module validation
This patch checks whether the diagnostic options that could lead to
errors (principally -Werror) are consistent between when a module was
built and when it is loaded. If there are new -Werror flags, then the
module is rebuilt. In order to canonicalize the options we do this
check at the level of the constructed DiagnosticsEngine, which contains
the final set of diag to diagnostic level mappings. Currently we only
rebuild with the new diagnostic options, but we intend to refine this in
the future to include the union of the new and old flags, since we know
the old ones did not cause errors. System modules are only rebuilt when
-Wsystem-headers is enabled.
One oddity is that unlike checking language options, we don’t perform
this diagnostic option checking when loading from a precompiled header.
The reason for this is that the compiler cannot rebuild the PCH, so
anything that requires it to be rebuilt effectively leaks into the build
system. And in this case, that would mean the build system
understanding the complex relationship between diagnostic options and
the underlying diagnostic mappings, which is unreasonable. Skipping the
check is safe, because these options do not affect the generated AST.
You simply won’t get new build errors due to changed -Werror options
automatically, which is also true for non-module cases.
Paul Robinson [Mon, 28 Apr 2014 22:24:44 +0000 (22:24 +0000)]
When Driver::generateCompilationDiagnostics is filtering the list of
inputs to the preprocessor, check for invalid types first because not
all linker inputs have an option value to retrieve.
David Majnemer [Mon, 28 Apr 2014 22:17:59 +0000 (22:17 +0000)]
CodeGen: Fix linkage of reference temporaries
Summary:
A reference temporary should inherit the linkage of the variable it
initializes. Otherwise, we may hit cases where a reference temporary
wouldn't have the same value in all translation units.
Chad Rosier [Mon, 28 Apr 2014 19:30:57 +0000 (19:30 +0000)]
[driver] Disable the slp vectorizer at -O0, -O1, and -Oz. This mirrors the
behavior of the loop vectorizer, which is enabled at -O2, -O3, -O4, -Ofast
and -Os.
PR19568
Alp Toker [Mon, 28 Apr 2014 02:39:27 +0000 (02:39 +0000)]
libclang: split out the documentation comment API
It's possible that the "comment AST" may be replaced or split out in the
midterm, any anyway this makes the headers easier to read.
Developers don't currently need to include "clang-c/Documentation.h" explicitly
and there's no macro to test for availability yet.
The raw comment and brief comment accessors have been kept in Index.h though
brief support may also move here as a separate proposal.
This is not a deprecation, just a gentle separation of concerns as we look to
simplify the built-in representation of comment nodes and support external
comment processors.
[Index/DocComments] When cloning a full comment, pick the template parameters from the original FullComment,
if the parameters are not already set (e.g. because it is a typedef).
Remove deprecated information about performances:
* It is better if we leave third parties to do "independent" benchmark.
* We compare Clang (version unspecified) with gcc 4.0 or 4.2.
* The graphs have not been updated for a while.
* Clang is well known now. I don't think we still need to explain why
Clang is great.
[SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there are no
designated initializers in the super class hierarchy then it should return false.
Alp Toker [Sat, 26 Apr 2014 14:43:53 +0000 (14:43 +0000)]
libclang: remove 'CXDiagnostic_Remark'
The change was landed without review or test cases.
It trivially broke almost any stable application checking for Severity >=
CXDiagnostic_Error or indeed any other kind of severity comparison upon
encountering a 'remark'.
Mapped to CXDiagnostic_Warning until a workable solution is proposed to the
list that preserves API stability.
(It's also not clear why the rest of r202475 wasn't simply implemented as a
modifier to the existing 'warning' level.)
Fixed Assert In CGRecordLowering
Prior to this patch, CGRecordLower assumed that virtual bases could not
be placed before the nvsize of an object. This isn't true in Itanium
mode, virtual bases are placed at dsize rather than vnsize and in the
case of zero sized non-virtual bases nvsize can be larger than dsize.
This patch fixes CGRecordLowering to avoid an assert and to clip
bitfields properly in this case. A test case is included.
The __yield intrinsic generates a hint instruction to indicate that the thread
is not performing any useful operations at the moment. This is for
compatibility with MSVC, although, the intrinsic is also part of the ACLE, and
is enabled globally as a result.
Benjamin Kramer [Fri, 25 Apr 2014 20:41:38 +0000 (20:41 +0000)]
Print detailed vector type information on diagnostics.
We never aka vector types because our attributed syntax for it is less
comprehensible than the typedefs. This leaves the user in the dark when
the typedef isn't named that well.
Example:
v2s v; v4f w;
w = v;
The naming in this cases isn't even that bad, but the error we give is
useless without looking up the actual typedefs.
t.c:6:5: error: assigning to 'v4f' from incompatible type 'v2s'
Now:
t.c:6:5: error: assigning to 'v4f' (vector of 4 'float' values) from
incompatible type 'v2s' (vector of 2 'int' values)
We do this for all diagnostics that print a vector type.
David Majnemer [Fri, 25 Apr 2014 17:08:41 +0000 (17:08 +0000)]
CodeGen: Cleanup variable linkage calculation
Almost all linkage calculation for VarDecls occured inside of
GetLLVMLinkageVarDefinition except for static data members. Centralize
the logic so that it can be more readily reused.
David Majnemer [Fri, 25 Apr 2014 17:07:16 +0000 (17:07 +0000)]
CodeGen: Refactor linkage/visibility calculation
It turns out that linkage and visibility have rather similar logic for
both functions and non-variable globals. Split the calculation out so
that both sides may share this code.