Richard Smith [Tue, 9 Jul 2013 00:57:56 +0000 (00:57 +0000)]
Generalize hack allowing 'const' in __has_attribute (etc) to allow any token
with identifier info. This covers most identifier-like entities (other than
the ISO646 keywords).
Attempt typo correction for function calls with the wrong number of arguments.
Combined with typo correction's new ability to apply global/absolute nested
name specifiers to possible corrections, cases such as in PR12287 where the
desired function is being shadowed by a lexically closer function with the
same name but a different number of parameters will now include a FixIt.
On a side note, since the test for this change caused
test/SemaCXX/typo-correction.cpp to exceed the typo correction limit for
a single file, I've included a test case for exceeding the limit and added
some comments to both the original and part two of typo-correction.cpp
warning future editors of the files about the limit.
Eli Friedman [Mon, 8 Jul 2013 20:20:06 +0000 (20:20 +0000)]
Fix Sema for compares with _Atomic vars.
Use UsualArithmeticConversions unconditionally in analysis of
comparisons and conditional operators: the method performs
the usual arithmetic conversions if both sides are arithmetic, and
usual unary conversions if they are not. This is just a cleanup
for conditional operators; for comparisons, it fixes the issue that
we would try to check isArithmetic() on an atomic type.
Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables
of atomic type correctly.
Fixed testcase failing under MS by adding "-fno-delayed-template-parsing",
as suggested by Takumi. To this end, added a MatchVerifier::match()
overload accepting a vector of invocation arguments.
Daniel Jasper [Mon, 8 Jul 2013 14:25:23 +0000 (14:25 +0000)]
Prefer similar line breaks.
This adds a penalty for clang-format for each break that occurs in
a set of parentheses (including fake parenthesis that determine
the range of certain operator precendences) that have not yet been
broken. Thereby, clang-format prefers similar line breaks.
This fixes llvm.org/PR15506.
Before:
const int kTrackingOptions =
NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited |
NSTrackingActiveAlways;
After:
const int kTrackingOptions = NSTrackingMouseMoved |
NSTrackingMouseEnteredAndExited |
NSTrackingActiveAlways;
Also removed ParenState::ForFakeParenthesis which has become unused.
Fix for corner cases in code handling leading "* " decorations in block comments
Summary:
Fixes problems that lead to incorrect formatting of these and similar snippets:
/*
**
*/
/*
**/
/*
* */
/*
*test
*/
Clang-format used to think that all the cases above use "* " decoration, and
failed to calculate insertion position properly. It also used to remove leading
"* " in the last line.
clang/test/Index/comment-custom-block-command.cpp: This has not been failing since r175892 on valgrind.
That said, it fails with --vg-leak. Mark it as XFAIL: vg_leak instead.
David Majnemer [Sun, 7 Jul 2013 23:49:50 +0000 (23:49 +0000)]
Sema: Do not merge new decls with invalid, old decls
Sema::MergeFunctionDecl attempts merging two decls even if the old decl
is invalid. This can lead to interesting circumstances where we
successfully merge the decls but the result makes no sense.
Take the following for example:
template <typename T>
int main(void);
int main(void);
Sema will not consider these to be overloads of the same name because
main can't be overloaded, which means that this must be a redeclaration.
In this case the templated decl is compatible with the non-templated
decl allowing the Sema::CheckFunctionDeclaration machinery to move on
and do bizarre things like setting the previous decl of a non-templated
decl to a templated decl!
The way I see it, we should just bail from MergeFunctionDecl if the old
decl is invalid.
James Dennett [Sun, 7 Jul 2013 05:19:50 +0000 (05:19 +0000)]
Documentation cleanup for include/clang/AST/DeclCXX.h, no substantive changes.
* Fix up \brief documentation;
* Update C++0x references to C++11;
* Doxygen formatting: bulleted lists start with a single hyphen, not two;
* Fix a typo, "assosiate" -> "associate".
David Majnemer [Sat, 6 Jul 2013 02:13:46 +0000 (02:13 +0000)]
Sema: Fix a crash when main is redeclared as a function-template.
This boils down to us sending invalid function decls to
CheckFunctionDeclaration becauswe we did not consider that CheckMain
could cause the decl to be invalid. Instead, interogate the new decl's
main-validity and *then* send it over to get CheckFunctionDeclaration'd
if it was still valid after calling CheckMain.
Eli Friedman [Fri, 5 Jul 2013 20:27:40 +0000 (20:27 +0000)]
Don't use mangleCXXRTTIName in TBAA for C code.
This changes the TBAA code so it doesn't use mangleCXXRTTIName in C,
because it doesn't really make sense there. Also, as sort of a
defense-in-depth change, fix the mangler so it handles C RecordDecls
correctly.
No tests because I don't know the TBAA code well enough to write a test,
and I don't know how else to trigger mangling a local struct in C.
Fixes a crash with r185450 reported by Joerg Sonnenberger.
Eli Friedman [Fri, 5 Jul 2013 18:41:30 +0000 (18:41 +0000)]
Fix regression from r185450.
As it turns out, the NoFunction bit for local class mangling needed to be
propagated into more places. r185450 turned what used to be an incorrect
mangling into an assertion.
We should not be asking unique_file to prepend the system temporary directory
when creating the html report. Unfortunately I don't think we can test this
with the current infrastructure since unique_file ignores MakeAbsolute if the
directory is already absolute and the paths provided by lit are.
I will take a quick look at making this api a bit less error prone.
Replace void with int to make this a valid C++ file.
The test was passing because clang would still print the ast before exiting
with an error. Since that didn't seem to be the intent of the test, I change
the test instead of adding 'not' to the command line.
Summary:
Always breaking before multiline strings can help format complex
expressions containing multiline strings more consistently, and avoid consuming
too much horizontal space.
Anna Zaks [Thu, 4 Jul 2013 02:38:10 +0000 (02:38 +0000)]
[analyzer] Suppress reports reported in std::list
The motivation is to suppresses false use-after-free reports that occur when calling
std::list::pop_front() or std::list::pop_back() twice. The analyzer does not
reason about the internal invariants of the list implementation, so just do not report
any of warnings in std::list.
Richard Smith [Thu, 4 Jul 2013 01:01:24 +0000 (01:01 +0000)]
Part of PR15673: If a function template has a default argument in which
substitution failed, report that as a substitution failure rather than
pretending that there was no default argument.
The test cases in PR15673 have exposed some pre-existing poor diagnostics here.
Richard Smith [Thu, 4 Jul 2013 00:13:48 +0000 (00:13 +0000)]
PR16480: Reimplement token-caching for constructor initializer lists. This
previously didn't work if a mem-initializer-id had a template argument which
contained parentheses or braces.
We now implement a simple rule: just look for a ') {' or '} {' that is not
nested. The '{' is assumed to start the function-body. There are still two
cases which we misparse, where the ') {' comes from a compound literal or
from a lambda. The former case is not valid C++, and the latter will probably
not be valid C++ once DR1607 is resolved, so these seem to be of low value,
and we do not regress on them with this change. EDG and g++ also misparse
both of these cases.
Bill Schmidt [Wed, 3 Jul 2013 20:54:09 +0000 (20:54 +0000)]
"bool" should be a context-sensitive keyword in Altivec mode.
PR16456 reported that Clang implements a hybrid between AltiVec's
"Keyword and Predefine Method" and its "Context Sensitive Keyword
Method," where "bool" is always a keyword, but "vector" and "pixel"
are context-sensitive keywords. This isn't permitted by the AltiVec
spec. For consistency with gcc, this patch implements the Context
Sensitive Keyword Method for bool, and stops treating true and false
as keywords in Altivec mode.
The patch removes KEYALTIVEC as a trigger for defining these keywords
in include/clang/Basic/TokenKinds.def, and adds logic for "vector
bool" that mirrors the existing logic for "vector pixel." The test
case is taken from the bug report.