Граф коммитов

2270 Коммитов

Автор SHA1 Сообщение Дата
Richard Smith 9f728cd374 Minor improvements to some C99 variadic-macro-related diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159054 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 23:59:08 +00:00
Kaelyn Uhrain c1fb542656 Perform typo correction for base class specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159046 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 23:37:05 +00:00
DeLesley Hutchins 0da4414f3d Thread safety analysis: fixes a bug in which locksets are not handled
properly if there is a join point in the control flow graph that involves
a trylock.  Also changes the source locations of some warnings to be
more consistent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159008 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 17:07:28 +00:00
Rafael Espindola 4e294eea2c Revert r158887. This fixes pr13168.
Revert "If an object (such as a std::string) with an appropriate c_str() member function"

This reverts commit 7d96f6106b.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158949 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 23:44:21 +00:00
David Blaikie 28a5f0cdfc PR13165: False positive when initializing member data pointers with NULL.
This now correctly covers, I believe, all the pointer types:
* 'any' pointers (both function and data normal pointers and ObjC object pointers)
* member pointers (both function and data)
* block pointers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158931 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 18:51:10 +00:00
Richard Smith 7d96f6106b If an object (such as a std::string) with an appropriate c_str() member function
is passed to a variadic function in a position where a format string indicates
that c_str()'s return type is desired, provide a note suggesting that the user
may have intended to call the c_str() member.

Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and
move it to SemaChecking in order to facilitate this. Factor the call checking
out of function call checking and block call checking, and extend it to cover
constructor calls too.

Patch by Sam Panzer!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158887 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 01:08:35 +00:00
Alexander Kornienko 86197b311d Added test with sizeof conditions (relies on to-be-implemented functionality of CFG, discussion: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120507/057370.html)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158854 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 21:12:23 +00:00
Jordan Rose 33c0f3703d Remove -Winternal-linkage-in-inline in C++.
It's very easy for anonymous external linkage to propagate in C++ through
return types and parameter types. Likewise, it's possible that a template
containing an inline function is only used with parameters that have internal
linkage. Actually diagnosing where the internal linkage comes from is fairly
difficult (both to locate and then to print nicely). Finally, since we only
have one translation unit available, we can't even prove that any of this
violates the ODR.

This warning needs better-defined behavior in C++ before it can really go in.

Rewording of the C warning (which /is/ specified by C99) coming shortly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 18:50:06 +00:00
Nico Weber ed36b2a808 Do a second lookup for type_info in the global namespace in microsoft mode. PR13153.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158768 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 23:58:27 +00:00
David Blaikie b26331b4ff Enable -Wnull-conversion for non-integral target types (eg: double).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158744 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 21:19:06 +00:00
Kaelyn Uhrain 0d3317e0a2 Improve the error message when a function overload candidate is rejected
because it expects a reference and receives a non-l-value.

For example, given:

  int foo(int &);
  template<int x> void b() { foo(x); }

clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158691 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 00:37:47 +00:00
Jordan Rose c4429b9ee5 Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).

This removes the warning entirely from uses in the main source file in C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158689 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 23:58:49 +00:00
Jordan Rose 0eb3f45a92 Support -Winternal-linkage-in-inline in C++ code.
This includes treating anonymous namespaces like internal linkage, and allowing
const variables to be used even if internal. The whole thing's been broken out
into a separate function to avoid nested ifs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158683 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 22:09:19 +00:00
Sean Hunt 93f95f2a2c Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158661 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 16:13:52 +00:00
Sean Hunt c2f51cfefd Stop referring to functions as methods in per-function fallthrough-checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158545 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 21:22:05 +00:00
Richard Trieu de5e75caac Use a proper visitor to recursively check for uninitialized use in constructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-14 23:11:34 +00:00
Daniel Jasper 0e9e9f8d17 Look at incomplete FunctionTemplateDecls in order to determine whether
a CXXRecordDecl is complete. Fixes Bug 13086.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158469 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-14 20:56:06 +00:00
Daniel Jasper 568eae48a4 Allow __attribute__((unused)) for fields and make it silence
-Wunused-private-field.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158411 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-13 18:31:09 +00:00
Richard Smith df9ef1bc8c PR13099: Teach -Wformat about raw string literals, UTF-8 strings and Unicode escape sequences.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158390 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-13 05:37:23 +00:00
Richard Smith 3c2fcf8705 PR12964: __int128 and unsigned __int128 are promoted integral types, be sure to
consider them when enumerating builtin operator candidates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158293 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-10 08:00:26 +00:00
Richard Smith 0f4b5be4a3 PR13051: Only suggest the 'template' and 'operator' keywords when performing
typo-correction after a scope specifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158231 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 21:35:42 +00:00
Richard Smith f4fe843aac Allow friend declarations of defaulted special member functions. Only
definitions of such members are prohibited, not mere declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158186 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 01:30:54 +00:00
Kaelyn Uhrain ef094a1ab7 Ignore corrections to functions with bodies when deciding which
correction to use for an invalid function redeclaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158177 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-07 23:57:08 +00:00
Kaelyn Uhrain 8d3607bf22 Allow CorrectTypo to add/modify nested name qualifiers to typos that
are otherwise too short to try to correct.

The TODOs added to two of the tests are for existing deficiencies in the
typo correction code that could be exposed by using longer identifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158109 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 20:54:51 +00:00
Daniel Jasper f8cc02e505 Introduce -Wunused-private-field. If enabled, this warning detects
unused private fields of classes that are fully defined in the current
translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158054 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 08:32:04 +00:00
Richard Smith 36d02af300 Add a warning for when an array-to-pointer decay is performed on an array
temporary or an array subobject of a class temporary, and the resulting value
is used to initialize a pointer which outlives the temporary. Such a pointer
is always left dangling after the initialization completes and the array's
lifetime ends.

In order to detect this situation, this change also adds an
LValueClassification of LV_ArrayTemporary for temporaries of array type which
aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++
(T){...} expressions, when T is an array type. Previously we treated the former
as a generic prvalue and the latter as a class temporary.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157955 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 22:27:30 +00:00
Aaron Ballman 287698336f Fixes some test cases that should have come along with r157943.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157947 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 20:07:46 +00:00
Aaron Ballman 44f5b1d95a Removing the lambda extension warning concerning single return statements, as it no longer applies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157943 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 18:57:41 +00:00
Douglas Gregor b1c6f5fa23 When adding built-in operator candidates for overload resolution
involving 'restrict', place restrict on the pointer type rather than
on the pointee type. Also make sure that we gather restrict from the
pointer type. Fixes PR12854 and the major part of PR11093.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157910 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 00:15:09 +00:00
Alexander Kornienko 1973634e44 Implementation of a "soft opt-in" option for -Wimplicit-fallthrough diagnostics: -Wimplicit-fallthrough-per-method
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157871 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-02 01:01:07 +00:00
Kaelyn Uhrain 784ae8e5c6 Don't allow multiple correction candidates that have the same identifier
but different nested name specifiers to quietly clobber each other so
only one remains if they do not refer to the same NamedDecl. Fixes
PR12951.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157823 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 18:11:16 +00:00
Aaron Ballman 1dfc4ba887 Anonymous union members within a struct are now properly handled as an unevaluated field in C++11 mode. This fixes PR12866.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157784 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 00:02:08 +00:00
Anna Zaks 90c78328e7 Change wording of 'memcpy' type mismatch warning and remove fixit.
As per comments following r157659.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157722 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 23:14:52 +00:00
David Blaikie abe21e36d7 Disable -Wunique-enum for anonymous enums.
This is a large class of false positives where anonymous enums are used to
declare constants (see Clang's Diagnostics.h for example). A small number of
true positives could probably be found in this bucket by still warning if the
anonymous enum is used in a declarator (enum { ... } x;) but so far we don't
believe this to be a source of significant benefit so I haven't bothered to
preserve those cases.

General offline review/acknowledgment by rtrieu.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157713 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 20:45:14 +00:00
Richard Trieu 7af7de7d6b Add new -Wunique-enum which will warn on enums which all elements have the
same value and were initialized with literals.  Clang will warn on code like
this:

enum A {
  FIRST = 1,
  SECOND = 1
};



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157666 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 01:01:11 +00:00
Anna Zaks 6fcb3727e3 Add fixits for memory access warnings.
Also, do not display the builtin name and macro expansion when the
function is a builtin.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157659 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 00:34:21 +00:00
Benjamin Kramer e0cf31dc26 PR12962: Fix a rare use after free when collecting virtual overrides.
The DenseMap reallocates after 64 insertions so this only happened in
large test cases under very specific circumstances.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157549 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-27 22:41:08 +00:00
Fariborz Jahanian 350e956532 -Wdeprecated warning to include reference (as a note)
to the declaration in this patch. // rdar://10893232


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157537 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-27 16:59:48 +00:00
Alexander Kornienko a189d8976f Don't offer '[[clang::fallthrough]];' fix-it when a fall-through occurs to a
switch label immediately followed by a 'break;'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-26 00:49:15 +00:00
Eli Friedman 4059da87fa A minor tweak to the new volatile lvalue warning: don't warn on "(void)x", where "x" refers to a local variable. This should silence a useless warning in compiler-rt and other places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157414 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 21:05:41 +00:00
Richard Smith 8ab10aa6be DR1152 / PR12931 / PR6177: A candidate function which requires binding a const
volatile reference to a temporary is not viable. My interpretation is that
DR1152 was a bugfix, not a rule change for C++11, so this is not conditional on
the language mode. This matches g++'s behavior.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157370 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 04:29:20 +00:00
Eli Friedman a6115068cd Add a warning to diagnose statements in C++ like "*(volatile int*)x;". Conceptually, this is part of -Wunused-value, but I added a separate flag -Wunused-volatile-lvalue so it doesn't get turned off by accident with -Wno-unused-value. I also made a few minor improvements to existing unused value warnings in the process. <rdar://problem/11516811>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157362 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 00:47:05 +00:00
Nico Weber 11d1a697dc Error when using typeid() with -fno-rtti. PR 12888.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157139 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-20 01:27:21 +00:00
Richard Smith 25582fc0ae Recover better from a missing 'typename' in a function template definition.
Disambiguate past such a potential problem, and use the absence of 'typename'
to break ties in favor of a parenthesized thingy being an initializer, if
nothing else in the declaration disambiguates it as declaring a function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156963 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 23:40:17 +00:00
David Blaikie def07624ec Include the correct conversion context locations for condition expressions.
This improves the conversion diagnostics (by correctly pointing to the loop
construct for conversions that may've been caused by the contextual conversion
to bool caused by a condition expression) and also causes the NULL conversion
warnings to be correctly suppressed when crossing a macro boundary in such a
context. (previously, since the conversion context location was incorrect, the
suppression could not be performed)

Reported by Nico Weber as feedback to r156826.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156901 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 04:20:04 +00:00
David Blaikie 9fb1ac520d Don't warn when NULL is used within a macro but its conversion is outside a macro.
This fixes the included test case & was reported by Nico Weber.

It's a little bit nasty using the difference in the conversion context, but
seems to me like a not unreasonable solution. I did have to fix up the
conversion context for conditional operators (it seems correct to me to include
the context for which we're actually doing the comparison - across all the
nested conditionals, rather than the innermost conditional which might not
actually have the problematic implicit conversion at all) and template default
arguments (this is a bit of a hack, since we don't have the source location of
the '=' anymore, so I just used the start of the parameter - open to
suggestions there)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156861 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:57:38 +00:00
Richard Smith 8f0a7e7845 If we see a declaration which is either missing a type or has a malformed type,
and the thing we have has a scope specifier, and we're in a context that doesn't
allow declaring a qualified name, then the error is a malformed type, not a
missing type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156856 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:29:55 +00:00
Richard Smith 827adaff66 Don't use the implicit int rule for error recovery in C++. Instead, try to
disambiguate whether the type name was forgotten or mistyped.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156854 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:01:51 +00:00
David Blaikie be0ee875d8 Improve some of the conversion warnings to fire on conversion to bool.
Moves the bool bail-out down a little in SemaChecking - so now
-Wnull-conversion and -Wliteral-conversion can fire when the target type is
bool.

Also improve the wording/details in the -Wliteral-conversion warning to match
the -Wconstant-conversion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156826 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 16:56:36 +00:00
Richard Smith c608c3c078 Further improvement to wording of overload resolution diagnostics, and including
the sole parameter name in the diagnostic in more cases. Patch by Terry Long!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156807 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 06:21:54 +00:00