Commit Graph

9344 Commits

Author SHA1 Message Date
Ted Kremenek a83b407c51 Reapply r172878 with test case.
llvm-svn: 172888
2013-01-19 04:33:14 +00:00
NAKAMURA Takumi 3fef3ef91d Whitespace.
llvm-svn: 172881
2013-01-19 01:54:35 +00:00
NAKAMURA Takumi 97e77abf83 Revert r172878, "Reword warning about using a *static* variable within its own initialization."
It broke, at least, linux, msvc and mingw bots.

llvm-svn: 172879
2013-01-19 01:47:46 +00:00
Ted Kremenek e07d167a50 Reword warning about using a *static* variable within its own initialization.
The warning is still under -Wuninitialized (although technically this
is defined behavior), but under a subgroup -Wstatic-self-init.

This addresses PR 10265.

llvm-svn: 172878
2013-01-19 00:49:00 +00:00
David Blaikie 68f71a3a78 Remove windows line endings.
llvm-svn: 172865
2013-01-18 23:03:15 +00:00
Douglas Gregor caddba9f00 Once we've collected the template arguments for a
partially-substituted parameter pack in a template, forget about the
partially-substituted parameter pack: it is now completed. Fixes
<rdar://problem/12176336>.

llvm-svn: 172859
2013-01-18 22:27:09 +00:00
Douglas Gregor 62ffead1ad When checking the parameter types of an Objective-C method, don't
decay the parameter type immediately; let CheckParameter() do its
job. Fixes <rdar://problem/12071218>.

llvm-svn: 172780
2013-01-18 01:41:40 +00:00
Douglas Gregor f4e43315a9 One can override an Objective-C ARC ownership qualifier that came from
a template parameter; make that also include one that came from
'auto'. Fixes <rdar://problem/12078752>.

llvm-svn: 172770
2013-01-17 23:59:28 +00:00
Douglas Gregor cd78037ad1 In Objective-C ARC, completely ignore ownership qualifiers on the
return type of a function by canonicalizing them away. They are
useless anyway, and conflict with our rules for template argument
deduction and __strong. Fixes <rdar://problem/12367446>.

llvm-svn: 172768
2013-01-17 23:36:45 +00:00
Richard Smith d33f5201b5 Defer checking for unsequenced operations on the RHS of && and || in order to
reduce stack usage and hopefully bring back the linux x86_64 buildbot.

llvm-svn: 172765
2013-01-17 23:18:09 +00:00
Richard Smith 0015f09877 Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
2013-01-17 22:16:11 +00:00
Richard Smith 01a7fba820 -Wunsequenced: if the LHS of an &&, || or ?: is not constant, check for
unsequenced operations in the RHS. We don't compare the RHS with the rest of
the expression yet; such checks will need care to avoid diagnosing unsequenced
operations which are both in conditionally-evaluated subexpressions which
actually can't occur together, such as in '(b && ++x) + (!b && ++x)'.

llvm-svn: 172760
2013-01-17 22:06:26 +00:00
Chad Rosier 4edf11fcf0 [ms-inline asm] Extend the Sema interface to get the size and length of a
VarDecl.
Part of rdar://12576868

llvm-svn: 172742
2013-01-17 19:21:24 +00:00
Joey Gouly 1d58cdbf4e Add some semantic checks for OpenCL. Variadic macros, VLAs and bitfields are not supported.
llvm-svn: 172732
2013-01-17 17:35:00 +00:00
David Blaikie b61b815fc8 Improve -Wreorder to handle cases of anonymous class member ordering
llvm-svn: 172707
2013-01-17 08:49:22 +00:00
David Blaikie 3fc2f9114a ArrayRef-ize some ctor initializer related APIs
llvm-svn: 172701
2013-01-17 05:26:25 +00:00
David Blaikie 3ae79d9b8b Remove some unnecessary casts
llvm-svn: 172700
2013-01-17 05:26:21 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Richard Smith 2ae0164fba Attempt to work around bug in older GCCs to fix buildbot.
llvm-svn: 172693
2013-01-17 01:40:50 +00:00
Richard Smith 10876ef571 Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).

llvm-svn: 172691
2013-01-17 01:30:42 +00:00
Richard Smith c406cb7364 Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn on
expressions which have undefined behavior due to multiple unsequenced
modifications or an unsequenced modification and use of a variable.

llvm-svn: 172690
2013-01-17 01:17:56 +00:00
Douglas Gregor eed4979db9 Treat hidden Objective-C protocol definitions as if they were
undefined, and don't find methods or protocols within those protocol
definitions. This completes <rdar://problem/10634711>.

llvm-svn: 172686
2013-01-17 00:38:46 +00:00
Dmitri Gribenko ae73417b69 Implement a fixit for -Wmain-return-type
llvm-svn: 172684
2013-01-17 00:26:13 +00:00
Rafael Espindola b306900200 Delay linkage checks when validating the weakref attribute.
llvm-svn: 172678
2013-01-16 23:49:06 +00:00
Aaron Ballman f96361e6cb Fixes crash when illegal function definitions are deleted or defaulted. Fixes PR14577.
llvm-svn: 172676
2013-01-16 23:39:10 +00:00
Rafael Espindola 7d9669e432 Simplify code. No functionality change.
llvm-svn: 172673
2013-01-16 23:21:32 +00:00
Rafael Espindola f1d2f0ea21 Check for internal weak decls after merging.
This fixes pr14946. The problem was that the linkage computation was done too
early, so things like "extern int a;" would be given external linkage, even if
a previous declaration was static.

llvm-svn: 172667
2013-01-16 23:11:15 +00:00
Douglas Gregor 048fbfa302 Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.
 

llvm-svn: 172665
2013-01-16 23:00:23 +00:00
Douglas Gregor 77f49a4902 Teach global selector lookup to ignore hidden methods, which occur
when the methods are declared in a submodule that has not yet been
imported. Part of <rdar://problem/10634711>. 

llvm-svn: 172635
2013-01-16 18:47:38 +00:00
Reed Kotler 373feca7a0 First step in implementation of mips16 and nomips16 attributes.
Waiting for new llvm attribute code for the next step.

llvm-svn: 172626
2013-01-16 17:10:28 +00:00
Douglas Gregor 43dc0c7d60 One can have an unavailable method overridden by an available method,
but not vice-versa. Fix bug introduced in r172567 and noticed by
Jordan, thanks!

llvm-svn: 172586
2013-01-16 00:54:48 +00:00
Douglas Gregor effe2a1e75 Apply adjustment to function- and array-typed non-type template
parameters (per C++ [temp.param]p8) when computing the type of a
reference to a non-type template parameter. Fixes <rdar://problem/13000548>.

llvm-svn: 172585
2013-01-16 00:52:15 +00:00
Douglas Gregor 66a8ca0f7f When checking availability attributes for consistency between an
overriding and overridden method, allow the overridden method to have
a narrower contract (introduced earlier, deprecated/obsoleted later)
than the overriding method. Fixes <rdar://problem/12992023>.

llvm-svn: 172567
2013-01-15 22:43:08 +00:00
David Greene a6394d0440 Fix Cast Code
Eliminate a cast and resulting cast-qual warning by using a temporary
as the target of memcpy.

llvm-svn: 172557
2013-01-15 22:09:39 +00:00
Richard Smith 03d9393b4a Don't crash when binding a reference to a temporary pointer created from
resolving an overloaded function reference within an initializer list.
Previously we would try to resolve the overloaded function reference without
first stripping off the InitListExpr wrapper.

llvm-svn: 172517
2013-01-15 07:58:29 +00:00
Richard Smith 550de45861 PR14950: Fix out-of-bounds function parameter access in literal operator lookup.
llvm-svn: 172514
2013-01-15 07:12:59 +00:00
Richard Smith 0faa2b1ae4 Fix behavior of [[gnu::]] function attributes. Per g++'s behavior, these
attributes appertain to a declaration, even though they would be much more
naturally modelled as appertaining to a function type. Previously, we would
try to distribute them from the declarator to the function type, then
reject them for being at an incorrect location. Now, we just distribute them
as far as the declarator; the existing attribute handling code can actually
apply them there just fine.

llvm-svn: 172504
2013-01-15 02:48:13 +00:00
Richard Smith 945f8d32fd Refactor to call ActOnFinishFullExpr on every full expression. Teach
ActOnFinishFullExpr that some of its checks only apply to discarded-value
expressions. This adds missing checks for unexpanded variadic template
parameter packs to a handful of constructs.

llvm-svn: 172485
2013-01-14 22:39:08 +00:00
Richard Smith 59b8e701d3 Fix regression in r172376. Don't try to detect missing 'constexpr' specifiers
on redeclarations, since that makes us pick wrong prior declarations under
some circumstances.

llvm-svn: 172384
2013-01-14 08:00:39 +00:00
Richard Smith 368ca52cd9 Accept [[gnu::*]] for all __attribute__((*))s which are:
1) Supported by Clang, and
 2) Supported by GCC, and
 3) Documented in GCC's manual.

g++ allows its C++11-style attributes to appertain only to the entity being
declared, and never to a type (even for a type attribute), so we do the same.

llvm-svn: 172382
2013-01-14 07:53:01 +00:00
Richard Smith 574f4f6a1d PR12008: defer adding the implicit 'const' to a constexpr member function until
we know whether it is static.

llvm-svn: 172376
2013-01-14 05:37:29 +00:00
Dmitri Gribenko 765396f2f0 ArrayRef'ize Sema APIs related to format string checking
llvm-svn: 172367
2013-01-13 20:46:02 +00:00
Richard Smith 1f5a4323e9 Remove some duplication in the handling of __attribute__((ext_vector_size(N))).
llvm-svn: 172340
2013-01-13 02:11:23 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Rafael Espindola 19de5613ea Disable caching of visibility.
The testcase in pr14929 shows that this is extremely hard to do. If we choose
to apply the attribute, that causes the visibility of some decls to change and
that can happen really late (during codegen).

Current gcc warns and ignores the attribute in this testcase with a warning.
This suggest that the correct solution is to find a point in the compilation
where we can compute the visibility and
* assert it was never computed before
* reject any attempts to compute it again in the future (with warnings).

llvm-svn: 172305
2013-01-12 06:42:30 +00:00
Rafael Espindola 7cf35ef8f6 Fix a regression from 171193: main cannot be overloaded.
Thanks Eli Friedman for noticing it.

llvm-svn: 172292
2013-01-12 01:47:40 +00:00
Douglas Gregor c147b0bc31 Provide Decl::getOwningModule(), which determines the (sub)module in
which a particular declaration resides. Use this information to
customize the "definition of 'blah' must be imported from another
module" diagnostic with the module the user actually has to
import. Additionally, recover by importing that module, so we don't
complain about other names in that module.

Still TODO: coming up with decent Fix-Its for these cases, and expand
this recovery approach for other name lookup failures.

llvm-svn: 172290
2013-01-12 01:29:50 +00:00
Richard Smith a7edaad3b6 Only produce one -Wc++98-compat warning when initializing a reference from an init list with multiple elements.
llvm-svn: 172285
2013-01-12 01:05:20 +00:00
Matt Beaumont-Gay b1e71a7d0c Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.

Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.

llvm-svn: 172279
2013-01-12 00:54:16 +00:00
Dmitri Gribenko bdc80de74c Constify parameter of clang::getCursorKindForDecl
llvm-svn: 172249
2013-01-11 20:32:41 +00:00