Most importantly, this makes our vtable layout match MSVC's. Previously
we would emit a return adjusting thunk whenever the return types
differed, even if the adjustment would have been trivial.
MSVC does emit some trivial return adjusting thunks, but only if there
was already an overridden method that required a return adjustment.
Nico Weber [Thu, 26 Dec 2013 23:38:39 +0000 (23:38 +0000)]
Warn on mismatched parentheses in memcmp and friends.
Thisadds a new warning that warns on code like this:
if (memcmp(a, b, sizeof(a) != 0))
The warning looks like:
test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]
if (memcmp(a, b, sizeof(a) != 0))
~~~~~~~~~~^~~~
test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?
if (memcmp(a, b, sizeof(a) != 0))
^ ~
)
test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning
if (memcmp(a, b, sizeof(a) != 0))
^
(size_t)( )
1 warning generated.
This found 2 bugs in chromium and has 0 false positives on both chromium and
llvm.
The idea of triggering this warning on a binop in the size argument is due to
rnk.
Warren Hunt [Thu, 26 Dec 2013 22:09:12 +0000 (22:09 +0000)]
[ms-abi] Fixes improperly sized vfptrs with pragma pack
With pragma pack, the layout engine would produce vfptrs that were
packed width rather than pointer width. This patch addresses the issue
and adds a test case.
Aaron Ballman [Thu, 26 Dec 2013 18:30:57 +0000 (18:30 +0000)]
Teach the diagnostics engine about the Attr type to make reporting on semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting.
Aaron Ballman [Thu, 26 Dec 2013 17:30:44 +0000 (17:30 +0000)]
Removed a string literal for an attribute name, which means the attribute name will be quoted in the diagnostic. Manually added some quotes to a diagnostic for consistency. Updated the test cases as appropriate.
Aaron Ballman [Thu, 26 Dec 2013 17:07:49 +0000 (17:07 +0000)]
This diagnostic did not accept arguments, and did not have any test coverage. Parameterized the diagnostic, and made it more consistent with other attribute diagnostic wordings. Added test coverage.
Since this warning was generalized, it was also given a sensible warning group flag and the corresponding test was updated to reflect this.
Aaron Ballman [Thu, 26 Dec 2013 14:54:11 +0000 (14:54 +0000)]
Removing some unneeded code, and a diagnostic that was obsoleted. The type has already been determined to be a ValueDecl by virtue of the attribute subjects.
Alp Toker [Tue, 24 Dec 2013 09:48:30 +0000 (09:48 +0000)]
Support and use token kinds as diagnostic arguments
Introduce proper facilities to render token spellings using the diagnostic
formatter.
Replaces most of the hard-coded diagnostic messages related to expected tokens,
which all shared the same semantics but had to be multiply defined due to
variations in token order or quote marks.
The associated parser changes are largely mechanical but they expose
commonality in whole chunks of the parser that can now be factored away.
This commit uses C++11 typed enums along with a speculative legacy fallback
until the transition is complete.
Hao Liu [Mon, 23 Dec 2013 02:44:00 +0000 (02:44 +0000)]
[AArch64]The compare to zero intrinsics should be implemented by 'icmp/fcmp' and 'sext' not 'zext'. Modify the implementation by replacing zext with sext.
Aaron Ballman [Sat, 21 Dec 2013 17:15:13 +0000 (17:15 +0000)]
Removing the alloc_size attribute. The attribute was semantically handled, but silently ignored. Most of this feature was already reverted in June 2012 (r159016), this just cleans up the pieces left over.
Aaron Ballman [Sat, 21 Dec 2013 16:49:29 +0000 (16:49 +0000)]
The const and nothrow attributes can be handled by the simple attribute handler. This removes a silent dropping of the attributes when they are duplicated on a Decl.
Richard Trieu [Sat, 21 Dec 2013 02:33:43 +0000 (02:33 +0000)]
Add -Winfinite-recursion to Clang
This new warning detects when a function will recursively call itself on every
code path though that function. This catches simple recursive cases such as:
This warning uses the CFG. As with other CFG-based warnings, this is off
by default. Due to false positives, this warning is also disabled for
templated functions.
Nico Weber [Sat, 21 Dec 2013 00:49:51 +0000 (00:49 +0000)]
Don't mark record decls invalid when one of its methods is invalid, PR18284.
Without this patch, record decls with invalid out-of-line method delcs would
sometimes be marked invalid, but not always. With this patch, they are
consistently never marked invalid.
(The code to do this was added in
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100809/033154.html
, but the test from that revision is still passing.)
As far as I can tell, this was the only place where a class was marked invalid
after its definition was complete.
David Blaikie [Fri, 20 Dec 2013 23:19:47 +0000 (23:19 +0000)]
DebugInfo: Do not include implicit members (implicit special members, template instantiations, etc) in the list of members of a structure.
These members will still be lazily added to the relevant DWARF DIEs in
LLVM but when enumerating the members they will not appear. This allows
DWARF type units to be more consistent - the type unit will never
contain these special members (so all instances of the type should have
the same DIEs without some having some special members and others having
others) and the special members will be added to the skeletal
declaration that appears in the relevant compile_unit.
Reid Kleckner [Fri, 20 Dec 2013 21:44:05 +0000 (21:44 +0000)]
Compare canonical return types when generating MS C++ ABI vtable thunks
This was part of the cause for PR17655. We were generating thunks when
we shouldn't have. I suspect that if we tweak the test case for PR17655
to actually require thunks, we can reproduce the same crash.
Daniel Jasper [Fri, 20 Dec 2013 12:09:36 +0000 (12:09 +0000)]
Enable layering check in unavailable modules.
If a header file belonging to a certain module is not found on the
filesystem, that header gets marked as unavailable. Now, the layering
warning (-fmodules-decluse) should still warn about headers of this
module being wrongfully included. Currently, headers belonging to those
modules are just treated as not belonging to modules at all which means
they can be included freely from everywhere.
To implement this (somewhat) cleanly, I have moved most of the layering
checks into the ModuleMap. This will also help with showing FixIts
later.
Jordan Rose [Fri, 20 Dec 2013 01:26:47 +0000 (01:26 +0000)]
Serialize source range info for TypeTraitExpr.
This caused some crazy crashes involving std::unordered_map being
deserialized from a PCH file and then template instantiation requiring
an explicit instantiation location; unfortunately I don't really know
how to come up with a minimal test case.
Dmitri Gribenko [Fri, 20 Dec 2013 00:16:25 +0000 (00:16 +0000)]
ASTUnit::getMainBufferWithPrecompiledPreamble: use MD5 hash of the remapped
files to tell if they were changed since the last time we have computed the
preamble
We used to check only the buffer size, so if the new remapped buffer has the
same size as the previous one, we would think that the buffer did not change,
and we did not rebuild the preambule, which sometimes caused us to crash.
Aaron Ballman [Thu, 19 Dec 2013 19:33:35 +0000 (19:33 +0000)]
No longer leaking Argument objects after calling createArgument. However, since an OwningPtr cannot live in a std::vector yet, there are some manual deletions that have a FIXME attached to them. These will go away once C++11 support is allowed.
Daniel Jasper [Thu, 19 Dec 2013 16:45:34 +0000 (16:45 +0000)]
clang-format: Increase penalty for breaking comments.
Unexpectedly, it seems that people commonly know what they were doing
when writing a comment.
Also, being more conservative about comment breaking has the advantage
of giving more flexibility. If a linebreak within the comment can
improve formatting, the author can add it (after which clang-format
won't undo it). There is no way to override clang-format's behavior if
it breaks a comment.
NAKAMURA Takumi [Thu, 19 Dec 2013 16:44:32 +0000 (16:44 +0000)]
[CMake][Standalone] Rewrite standalone build based on llvm-config. CLANG_PATH_TO_LLVM_*(s) are deprecated.
Checked on VS10(multiconfig) and some singleconfig builders.
* Assumptions
- You should specify llvm-config as LLVM_CONFIG.
CMake could find one in $PATH by default.
- ENABLE_ASSERTIONS obeys LLVM's.
* Use cases
a) With LLVM build tree
Assume llvm-config is in your build tree.
Everything should work as ever.
b) With *installed* LLVM
Assume distributions. The source tree can be optional.
b1) The source tree is provided on the location `llvm-config --src-root`
- Test utils, FileCheck &c., are imported and built in the new tree.
- Gtest is built in the tree if gtest library is not found.
- Lit is used in $(SRCROOT)/utils/lit/lit.py.
b2) The source tree is not provided
- clang and utilities can be built.
- All tests, unittests and check-clang are invalidated and not built.
Aaron Ballman [Thu, 19 Dec 2013 13:16:35 +0000 (13:16 +0000)]
Hosting a call to getAttr so that we don't call it multiple times for the same attribute. Also removes a hasAttr that's not required. No functional changes intended.
Aaron Ballman [Thu, 19 Dec 2013 02:58:51 +0000 (02:58 +0000)]
Switched code from using hasAttr followed by getAttr to simply call getAttr directly and check the resulting value. Also fixes some minor formatting issues surrounding the getAttr code.
Dmitri Gribenko [Thu, 19 Dec 2013 02:05:20 +0000 (02:05 +0000)]
PCH: fix a crash caused by a circular deserialization dependency
We started by trying to deserialize decltype(func-param) in a trailing return
type, which causes the function parameter decl to be deserialized, which pulls
in the function decl, which pulls the function type, which pulls the same
decltype() in the return type, and then we crashed.