Commit Graph

1547 Commits

Author SHA1 Message Date
David Majnemer 03f705fe92 Sema: Don't allow CVR qualifiers before structors
We would silently accept volatile ~S() when the user probably intended
to write virtual ~S().

This fixes PR20238.

llvm-svn: 212555
2014-07-08 18:18:04 +00:00
Alp Toker d0787ebf5e Introduce a FunctionDecl::getReturnTypeSourceRange() utility
This source range is useful for all kinds of diagnostic QOI and refactoring
work, so let's make it more discoverable.

This commit also makes use of the new function to enhance various diagnostics
relating to return types and resolves an old FIXME.

llvm-svn: 212154
2014-07-02 01:47:15 +00:00
Craig Topper 7e0daca110 Convert some function arguments to use ArrayRef.
llvm-svn: 211764
2014-06-26 04:58:53 +00:00
Hans Wennborg 9bea9cc73b MS ABI: Propagate class-level DLL attributes to class template specialization bases (PR11170)
Consider the following code:

  template <typename T> class Base {};
  class __declspec(dllexport) class Derived : public Base<int> {}

When the base of an exported or imported class is a class template
specialization, MSVC will propagate the dll attribute to the base.
In the example code, Base<int> becomes a dllexported class.

This commit makes Clang do the proopagation when the base hasn't been
instantiated yet, and warns about it being unsupported otherwise.
This is different from MSVC, which allows changing a specialization
back and forth between dllimport and dllexport and seems to let the
last one win. Changing the dll attribute after instantiation would be
hard for us, and doesn't seem to come up in practice, so I think this
is a reasonable limitation to have.

MinGW doesn't do this kind of propagation.

Differential Revision: http://reviews.llvm.org/D4264

llvm-svn: 211725
2014-06-25 18:25:57 +00:00
Richard Smith 085a64ffc5 [C++1z] Implement N3928: message in static_assert is optional.
llvm-svn: 211394
2014-06-20 19:57:12 +00:00
Daniel Jasper b3b0b8034c Fix/Improve SourceRange of explicitly defaulted members
When adding the implicit compound statement (required for Codegen?), the
end location was previously overridden by the start location, probably
based on the assumptions:

* The location of the compound statement should be the member's location
* The compound statement if present is the last element of a FunctionDecl

This patch changes the location of the compound statement to the
member's end location.

Code review: http://reviews.llvm.org/D4175

llvm-svn: 211344
2014-06-20 08:44:22 +00:00
Hans Wennborg ef2272c49e Inherit dll attributes to static locals
This makes us handle static locals in exported/imported functions correctly.

Differential Revision: http://reviews.llvm.org/D4136

llvm-svn: 211173
2014-06-18 15:55:13 +00:00
Alp Toker d4a3f0e894 Hide the concept of diagnostic levels from lex, parse and sema
The compilation pipeline doesn't actually need to know about the high-level
concept of diagnostic mappings, and hiding the final computed level presents
several simplifications and other potential benefits.

The only exceptions are opportunistic checks to see whether expensive code
paths can be avoided for diagnostics that are guaranteed to be ignored at a
certain SourceLocation.

This commit formalizes that invariant by introducing and using
DiagnosticsEngine::isIgnored() in place of individual level checks throughout
lex, parse and sema.

llvm-svn: 211005
2014-06-15 23:30:39 +00:00
David Majnemer 5ef4fe7d8e MS ABI: Fix inheritance model calculation in CRTP
CRTP-like patterns involve a class which inherits from another class
using itself as a template parameter.

However, the base class itself may try to create a pointer-to-member
which involves the derived class.  This is problematic because we
may not have finished parsing the most derived classes' base specifiers
yet.

It turns out that MSVC simply uses the unspecified inheritance model
instead of doing anything fancy.

This fixes PR19987.

llvm-svn: 210886
2014-06-13 06:43:46 +00:00
Reid Kleckner 6713086bca Check the access of operator delete from the destructor context
Previously we would do the access check from the context of
MarkVTableUsed.

Also update this test to C++11, since that is typically used with the MS
C++ ABI.

Fixes PR20005.

llvm-svn: 210850
2014-06-12 22:39:12 +00:00
Hans Wennborg e8ad3839a1 Don't inherit dllimport to inline move assignment operators
Current MSVC versions don't have move assignment operators, so we
can't rely on them being available in the dll. If we have the
definition, we can just use that directly. This breaks pointer
equality, but should work fine otherwise.

When there is an MSVC version that supports move assignment,
we can key this off the -fmsc-ver option.

http://reviews.llvm.org/D4105

llvm-svn: 210715
2014-06-11 22:44:39 +00:00
Hans Wennborg 9d06a8d060 Don't inherit dll attributes to deleted methods (PR19988)
We would previously end up with an error when instantiating the
following template:

  template <typename> struct __declspec(dllimport) S {
    void foo() = delete;
  };
  S<int> s;

error: attribute 'dllimport' cannot be applied to a deleted function
llvm-svn: 210550
2014-06-10 17:53:23 +00:00
Richard Trieu ddd01cec0e Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context.  The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.

llvm-svn: 210498
2014-06-09 22:53:25 +00:00
Alp Toker 15e62a37f0 Fix typos
llvm-svn: 210328
2014-06-06 12:02:07 +00:00
Aaron Ballman 9ef622e5bf The exception-declaration for a function-try-block cannot redeclare a
function parameter. One of our existing test cases was XFAILed because
of this. This fixes the issue and un-XFAILs the test.

llvm-svn: 210026
2014-06-02 13:10:07 +00:00
Hans Wennborg 496524b448 Diagnose dll attribute on member of class that already has a dll attribute
Differential Revision: http://reviews.llvm.org/D3973

llvm-svn: 209954
2014-05-31 02:08:49 +00:00
Hans Wennborg 853ae94660 Start adding support for dllimport/dllexport on classes (PR11170)
This implements the central part of support for dllimport/dllexport on
classes: allowing the attribute on class declarations, inheriting it
to class members, and forcing emission of exported members. It's based
on Nico Rieck's patch from http://reviews.llvm.org/D1099.

This patch doesn't propagate dllexport to bases that are template
specializations, which is an interesting problem. It also doesn't
look at the rules when redeclaring classes with different attributes,
I'd like to do that separately.

Differential Revision: http://reviews.llvm.org/D3877

llvm-svn: 209908
2014-05-30 16:59:42 +00:00
Nico Rieck 9de0a57687 Sema: Functions with dll attributes cannot be deleted
llvm-svn: 209827
2014-05-29 16:51:19 +00:00
Nikola Smiljanic 03ff2596cb Refactoring. Remove Owned method from Sema.
llvm-svn: 209812
2014-05-29 14:05:12 +00:00
Nikola Smiljanic 01a7598561 Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
llvm-svn: 209800
2014-05-29 10:55:11 +00:00
Alp Toker 2afa8780d6 Consolidate some note diagnostics
These note diags have the same message and can be unified further but for now
let's just bring them together.

Incidental change: Display a source range in the final attr diagnostic.

llvm-svn: 209728
2014-05-28 12:20:14 +00:00
Craig Topper c3ec149bb2 [C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
2014-05-26 06:22:03 +00:00
Nikola Smiljanic 3a01af0805 PR19352 - getLocation() points to the wrong position for FriendDecls
llvm-svn: 209511
2014-05-23 12:48:27 +00:00
Yaron Keren 885ea4253d DeclVisitor is not used here.
llvm-svn: 209285
2014-05-21 09:02:49 +00:00
Yaron Keren 065da7c53a Fixed spelling.
llvm-svn: 209224
2014-05-20 18:23:05 +00:00
Alp Toker 4284c6e7a4 Consolidate single void paramter checking
Also correct argument/parameter terminology.

No change in functionality.

llvm-svn: 208498
2014-05-11 16:05:55 +00:00
David Blaikie 04e2e665cb Don't emit -Wnon-virtual-dtor on final classes, since it's not a problem there.
The base class is the culprit/risk here - a sealed/final derived class
with virtual functions and a non-virtual dtor can't accidentally be
polymorphically destroyed (if the base class's dtor is protected - which
also suppresses this warning).

llvm-svn: 208449
2014-05-09 22:02:28 +00:00
Alp Toker a030cd0558 StringRefize and take out an old FIXME
llvm-svn: 207962
2014-05-05 12:38:48 +00:00
Nick Lewycky d78f92fbb2 Rewrite NRVO determination. Track NRVO candidates on the parser Scope and apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal.
Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith.

llvm-svn: 207890
2014-05-03 00:41:18 +00:00
Hans Wennborg b6d4e8cd4e Handle -fdelayed-template-parsing of out-of-line definitions of
class template member classes (PR19613)

Also improve this code in general by implementing suggestions
from Richard.

Differential Revision: http://reviews.llvm.org/D3555?id=9020

llvm-svn: 207822
2014-05-02 02:01:07 +00:00
Richard Smith 09d5b3a928 Make typo-correction of inheriting constructors work a bit better. Limit
correction to direct base class members, and recover properly after we apply
such a correction.

llvm-svn: 207731
2014-05-01 00:35:04 +00:00
Richard Smith d94f2f16bd When typo-correcting a member using declaration, don't exclude member templates.
llvm-svn: 207681
2014-04-30 18:15:00 +00:00
Richard Smith 21866c3267 When typo-correcting a member using-declaration, only consider members of base classes.
llvm-svn: 207680
2014-04-30 18:03:21 +00:00
Richard Smith 30a615dca8 Fix crash if typo correction corrects a member using-declaration to a
non-member declaration. Patch by Dinesh Dwivedi!

llvm-svn: 207677
2014-04-30 17:40:35 +00:00
John Thompson 2255f2ce90 Initial implementation of -modules-earch-all option, for searching for symbols in non-imported modules.
llvm-svn: 206977
2014-04-23 12:57:01 +00:00
Richard Smith 06ffb45ce4 PR18746: If a constexpr function has a dependent return type and no return
statements, don't diagnose; the return type might end up being 'void'.

Patch by Rahul Jain! Tiny tweaks by me.

llvm-svn: 206929
2014-04-22 23:14:23 +00:00
Richard Smith cd45dbc5f2 When a module completes the definition of a class template specialization imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations.
llvm-svn: 206680
2014-04-19 03:48:30 +00:00
Richard Smith 4b55a9c841 Refactor all the checking for missing 'template<>'s when a declaration has a
template-id after its scope specifier into a single place.

llvm-svn: 206442
2014-04-17 03:29:33 +00:00
Richard Smith 82dce550c8 PR19415: Converting 'constexpr' to 'const' in a non-static data member can fail
if the member is already 'const'. Don't assert in that case.

llvm-svn: 206205
2014-04-14 21:00:40 +00:00
Richard Smith 83e78f5c3c Fix handling of redeclaration lookup for using declarations, where the prior
declaration is not visible. Previously we didn't find hidden friend names in
this redeclaration lookup, because we forgot to treat it as a redeclaration
lookup. Conversely, we did find some local extern names, but those don't
actually conflict with a namespace-scope using declaration, because the only
conflicts we can get are scope conflicts, not conflicts due to the entities
being members of the same namespace.

llvm-svn: 206011
2014-04-11 01:03:38 +00:00
Richard Smith 7ad0b88396 If a using-declaration names a class member, but appears outside a class, try
to suggest a different syntax to get the same effect.

llvm-svn: 205467
2014-04-02 21:44:35 +00:00
David Majnemer ee4f4025c3 Sema: Implement DR317
Summary:
Declaring a function as inline after it has been defined is in violation
of [dcl.fct.spec]p4.  The program would get a strong definition instead
of getting a function with linkonce_odr linkage.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3220

llvm-svn: 205129
2014-03-30 06:44:54 +00:00
Stephan Tolksdorf 5604a27788 Don't emit exit-time destructor warnings for trivial explicitly defaulted dtors
This commit also adds an additional test case for the global destructor warning.

Reviewed in http://llvm-reviews.chandlerc.com/D3205

llvm-svn: 204954
2014-03-27 20:23:36 +00:00
Reid Kleckner c511f43b67 -Wglobal-constructors: Don't warn on trivial defaulted dtors
Fixes PR19253.

llvm-svn: 204825
2014-03-26 15:58:20 +00:00
Richard Smith 564417a071 When the exception specification for a function in an imported PCH or module is
resolved, emit an update record.

llvm-svn: 204403
2014-03-20 21:47:22 +00:00
Aaron Ballman 18d85aed39 Replacing the exclusive_lock_function, shared_lock_function and unlock_function attributes with the acquire_capability and release_capability attributes. The old spellings will continue to work, but the underlying semantic attributes have been replaced.
Downgraded the capability diagnostics from error to warning to match the desired behavior, and updated the existing test cases.

llvm-svn: 204350
2014-03-20 16:02:49 +00:00
Aaron Ballman b088fbee3f [C++11] Replacing FunctionProtoType iterators exception_begin() and exception_end() with iterator_range exceptions(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 204046
2014-03-17 15:38:09 +00:00
Aaron Ballman c7e4e219b5 [C++11] Replacing CompoundStmt iterators body_begin() and body_end() with iterator_range body(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 204040
2014-03-17 14:19:37 +00:00
Aaron Ballman 535bbcccb1 [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with iterator_range decls(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203947
2014-03-14 17:01:24 +00:00
Aaron Ballman 0ad78303de [C++11] Replacing CXXRecordDecl iterators init_begin() and init_end() with iterator_range inits(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203819
2014-03-13 17:34:31 +00:00