[C++11] Remove a now unnecessary use of std::function for a remove_if
predicate. The wrapper used by SetVector was erroneously requiring an
adaptable predicate. It has been fixed and we really don't want to
require an indirect call for every predicate evaluation.
Jordan Rose [Mon, 3 Mar 2014 18:29:52 +0000 (18:29 +0000)]
Serialized diagnostic severity levels should be stable.
Serialized diagnostics were accidentally using the AST diagnostic level values
rather than a dedicated stable enum, so the addition of "remark" broke the
reading of existing serialized diagnostics files. I've added a .dia file
generated from Xcode 5's Clang to make sure we don't break this in the future.
Disable all dependency output options when using the Tooling library.
It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).
If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.
Hal Finkel [Sun, 2 Mar 2014 18:24:18 +0000 (18:24 +0000)]
Add a PPC inline asm constraint type for single CR bits
This adds support for the PPC "wc" inline asm constraint (used for allocating
individual CR bits). Support for this constraint type was recently added to the
LLVM PowerPC backend. Although gcc does not currently support allocating
individual CR bits, this identifier choice has been coordinated with the gcc
PowerPC team, and will be marked as reserved for this purpose in the gcc
constraints.md file.
Prior to this change, none of the multi-character PPC constraints were handled
correctly (the '^' escape character was not being added as required by the
parsing code in LLVM). This should now be fixed. I'll add tests for these other
constraints as support is added for them in the backend.
[C++11] Switch the clang-format LLVM style to use C++11 style braced
init list formatting. This suggestion has now gone into the LLVM coding
standards, and is particularly relevant now that we're using C++11.
Updated a really ridiculous number of tests to reflect this change.
Warren Hunt [Sat, 1 Mar 2014 00:38:40 +0000 (00:38 +0000)]
Fixed an assertion failure related to bitfield lowering.
When lowering a bitfield, CGRecordLowering would assign the wrong
storage type to a bitfield in some cases and trigger an assertion. In
these cases the layout was still correct, just the bitfield info was
wrong.
Richard Smith [Sat, 1 Mar 2014 00:08:04 +0000 (00:08 +0000)]
If a module A exports a macro M, and a module B imports that macro and #undef's
it, importers of B should not see the macro. This is complicated by the fact
that A's macro could also be visible through a different path. The rules (as
hashed out on cfe-commits) are included as a documentation update in this
change.
With this, the number of regressions in libc++'s testsuite when modules are
enabled drops from 47 to 7. Those remaining 7 are also macro-related, and are
due to remaining bugs in this change (in particular, the handling of submodules
is imperfect).
Reid Kleckner [Fri, 28 Feb 2014 23:46:04 +0000 (23:46 +0000)]
Add Clang docs about MSVC compatibility
This documents some of the status of supported functionality in MSVC
quirks mode. Some of this should be in
http://clang.llvm.org/compatibility.html instead when things have
stabilized.
Ben Langmuir [Fri, 28 Feb 2014 21:16:07 +0000 (21:16 +0000)]
Reapply fixed "Honour 'use-external-names' in FileManager"
Was r202442
There were two issues with the original patch that have now been fixed.
1. We were memset'ing over a FileEntry in a test case. After adding a
std::string to FileEntry, this still happened to not break for me.
2. I didn't pass the FileManager into the new compiler instance in
compileModule. This was hidden in some cases by the fact I didn't
clear the module cache in the test.
Also, I changed the copy constructor for FileEntry, which was memcpy'ing
in a (now) unsafe way.
Anders Carlsson [Fri, 28 Feb 2014 19:07:22 +0000 (19:07 +0000)]
When completing Objective-C instance method invocations, perform a contextual conversion to an Objective-C pointer type of the target expression if needed. This fixes code completion of method invocations where the target is a smart pointer that has an explicit conversion operator to an Objective-C type.
Kaelyn Uhrain [Fri, 28 Feb 2014 18:12:42 +0000 (18:12 +0000)]
Don't suggest non-static methods as corrections when they obviously
won't work (i.e. when not doing a member lookup and not in a method from
the same class or a descendant class).
Tobias Grosser [Fri, 28 Feb 2014 09:11:08 +0000 (09:11 +0000)]
Add 'remark' diagnostic type in 'clang'
A 'remark' is information that is not an error or a warning, but rather some
additional information provided to the user. In contrast to a 'note' a 'remark'
is an independent diagnostic, whereas a 'note' always depends on another
diagnostic.
A typical use case for remark nodes is information provided to the user, e.g.
information provided by the vectorizer about loops that have been vectorized.
This patch provides the initial implementation of 'remarks'. It includes the
actual definiton of the remark nodes, their printing as well as basic parameter
handling. We are reusing the existing diagnostic parameters which means a remark
can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded to
an error using '-Werror=diagnostic-name'. '-Werror' alone does not upgrade
remarks.
This patch is by intention minimal in terms of parameter handling. More
experience and more discussions will most likely lead to further enhancements
in the parameter handling.
Richard Smith [Fri, 28 Feb 2014 01:36:39 +0000 (01:36 +0000)]
Add a -Wclass-varargs to warn on objects of any class type being passed through an ellipsis. Since C++11 relaxed the rules on this, we allow a lot more bad code through silently, such as:
Ben Langmuir [Thu, 27 Feb 2014 23:27:54 +0000 (23:27 +0000)]
Honour 'use-external-names' in FileManager
Pass through the externally-visible names that we got from the VFS down
to FileManager, and test that this is the name showing up in __FILE__,
diagnostics, and debug information.
Bob Wilson [Thu, 27 Feb 2014 21:59:17 +0000 (21:59 +0000)]
Remove an assertion that no longer holds. <rdar://problem/16135814>
In r201528, I changed the PGO instrumentation counter for a "do" loop to not
include the fall-through count. That fall-through count is included later, b
it means that this assertion may fail for "do" loops.
Ted Kremenek [Thu, 27 Feb 2014 21:56:47 +0000 (21:56 +0000)]
[-Wunreachable-code] always treat 'case:' and 'default:' cases as reachable.
This is a heuristic. Many switch statements, although they look covered
over an enum, may actually handle at runtime more values than in the enum.
This is overly conservative, as there are some cases that clearly
can be ruled as being clearly unreachable, e.g. 'switch (42) { case 1: ... }'.
We can refine this later.
John McCall [Thu, 27 Feb 2014 20:30:49 +0000 (20:30 +0000)]
Diagnose attempts to apply ms_struct to records with base classes
or virtual functions, but permit that error to be downgraded to
a warning (with -Wno-error=incompatible-ms-struct), and officially
support this kind of dual, ABI-mixing layout.
The basic problem here is that projects which use ms_struct are often
not very circumspect about what types they annotate; for example,
some projects enable the pragma in a prefix header and then only
selectively disable it around system header inclusions. They may
only care about binary compatibility with MSVC for a subset of
those structs, but that doesn't mean they have no binary
compatibility concerns at all for the rest; thus we are essentially
forced into supporting this hybrid ABI. But it's reasonable for
us to at least point out the places where we're not making
any guarantees.
The original diagnostic was for dynamic classes, i.e. those with
virtual functions or virtual bases; I've extended it to include
all classes with bases, because we are not actually making any
attempt to duplicate MSVC's base subobject layout in ms_struct
(and it is indeed quite different from Itanium, even for
non-virtual bases).
Reid Kleckner [Thu, 27 Feb 2014 19:40:09 +0000 (19:40 +0000)]
MS ABI: Fix vftable mangling by using the vbtable name algorithm
Summary:
This merges VFPtrInfo and VBTableInfo into VPtrInfo, since they hold
almost the same information. With that change, the vbtable mangling
code can easily be applied to vftable data and we magically get the
correct, unambiguous vftable names.
Ben Langmuir [Thu, 27 Feb 2014 19:14:03 +0000 (19:14 +0000)]
Remove constructors from FileEntry that prevent owning resources
This cleans up some constructors that would not be safe once FileEntry
owns the storage for its name. These were already suspect, since they
wouldn't work if the FileEntry had an open file descriptor. The only
user for these constructors was in UniqueFileContainer, which wasn't a
very useful abstraction anyway. So it and UniqueDirContainer have been
replaced with std::map<UniqueID, *>.
This change should not affect anything outside the FileManager.
Rafael Espindola [Thu, 27 Feb 2014 19:01:11 +0000 (19:01 +0000)]
Use private linkage for globals we already name with \01L and \01l.
In llvm the only semantic difference between internal and private is that llvm
tries to hide private globals my mangling them with a private prefix. Since
the globals changed by this patch already had the magic don't mangle marker,
there should be no change in the generated assembly.
A followup patch should then be able to drop the \01L and \01l prefixes and let
llvm mangle as appropriate.
Alexey Samsonov [Thu, 27 Feb 2014 09:09:39 +0000 (09:09 +0000)]
[CMake] Teach build system to build/test compiler-rt with a just-built Clang
With this change, one may set LLVM_BUILD_EXTERNAL_COMPILER_RT option
to build compiler-rt libraries with just-built Clang.
make compiler-rt
in the build tree will build all compiler-rt libraries with just-built Clang
and copy them to the proper location in the Clang resource directory.
make check-compiler-rt
will run the compiler-rt test suite using just-built Clang and runtime
libraries.
The goal is to make LLVM_BUILD_EXTERNAL_COMPILER_RT the default, so that
we can always build compiler-rt libraries with Clang, not the host compiler,
and for all the platforms Clang can target.
[ASTUnit] Fix use-after-free bug in ASTUnit::getMainBufferWithPrecompiledPreamble().
With r197755 we started reading the contents of buffer file entries, but the
buffers may point to ASTReader blobs that have been disposed.
Fix this by having the CompilerInstance object keep a reference to the ASTReader
as well as having the ASTContext keep reference to the ExternalASTSource.
This was very difficult to construct a test case for.
rdar://16149782
Ted Kremenek [Thu, 27 Feb 2014 01:28:58 +0000 (01:28 +0000)]
Add category test case for attribute 'objc_protocol_requires_explicit_implementation'.
This test also illustrates that checking for properties is not working properly with
this attribute, as we are missing a diagnostic for a property not being implemented.
Ben Langmuir [Thu, 27 Feb 2014 00:25:12 +0000 (00:25 +0000)]
Add a 'use-external-names' option to VFS overlay files
When true, sets the name of the file to be the name from
'external-contents'. Otherwise, you get the virtual path that the file
was looked up by. This will not affect any non-virtual paths, or fully
virtual paths (for which there is no reasonable 'external' name anyway).
The setting is available globally, but can be overriden on a per-file
basis.
The goal is that this setting will control which path you see in debug
info, diagnostics, etc. which are sensitive to which path is used. That
will come in future patches that pass the name through to FileManager.