Commit Graph

1687 Commits

Author SHA1 Message Date
Xiuli Pan 97f9428a0d [OpenCL] Pipe type support
Summary:
Support for OpenCL 2.0 pipe type.
This is a bug-fix version for bader's patch reviews.llvm.org/D14441


Reviewers: pekka.jaaskelainen, Anastasia

Subscribers: bader, Anastasia, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257254 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-09 12:53:17 +00:00
David Majnemer a32c3cb5f6 [MSVC Compat] Diagnose multiple default ctors for dllexport'd classes
The MS ABI emits a special default constructor closure thunk if a
default constructor has a weird calling convention or default arguments.

The MS ABI has a quirk: there can be only one such thunk because the
mangling scheme does not have room for distinct manglings.  We must
raise a diagnostic in this eventuality.

N.B.  MSVC sorta gets this right.  Multiple default constructors result
in the default constructor closure getting emitted but they seem to
get confused by which default constructors are reasonable to reference
from the closure.  We try to be a little more careful which results in
mild differences in behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256661 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-31 05:36:46 +00:00
Richard Smith 13e4061bde When a namespace alias redeclares a using declaration, point the diagnostic at
the using declaration not at the thing it's using.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256602 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 23:42:34 +00:00
Richard Smith 25c4910963 Model NamespaceAliasDecls as having their nominated namespace as an underlying
declaration. This fixes an issue where we would reject (due to a claimed
ambiguity) a case where lookup finds multiple NamespaceAliasDecls from
different scopes that nominate the same namespace.

The C++ standard doesn't make it clear that such a case is in fact valid (which
I'm working on fixing), but there are no relevant rules that distinguish using
declarations and namespace alias declarations here, so it makes sense to treat
them the same way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256601 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 23:34:32 +00:00
Richard Smith b46f944564 Teach typo correction to properly handle mapping declarations to their
underlying decls. Preserve the found declaration throughout, and only map to
the underlying declaration when we want to check whether it's the right kind.
This allows us to provide the right source location for the found declaration,
and prepares for the possibility of underlying decls with a different name
from the found decl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256575 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 19:43:10 +00:00
Serge Pavlov 59d0d7461d Do not crash if class is defined in wrong scope.
This patch fixes PR16677. The latter represents the case when due to
misprinted character class definition occurs in the scope of template
arguments. Base class of this class depends on the template parameter in the
same scope and cannot be resolved, it causes crash. Right behavior is to
make semantic processing even if the definition is wrong, as the code
that emits appropriate message is called after the processing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256511 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-28 19:40:14 +00:00
Craig Topper b4bb09f763 [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256478 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-27 21:55:19 +00:00
Craig Topper cde3c8b572 Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"
It broke lldb build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256403 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-25 00:36:02 +00:00
Craig Topper 9436b97369 [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256399 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-24 23:58:20 +00:00
Richard Smith 5dbd903a7e Split RequireCompleteType into a function that actually requires that the type
is complete (with an error produced if not) and a function that merely queries
whether the type is complete. Either way we'll trigger instantiation if
necessary, but only the former will diagnose and recover from missing module
imports.

The intent of this change is to prevent a class of bugs where code would call
RequireCompleteType(..., 0) and then ignore the result. With modules, we must
check the return value and use it to determine whether the definition of the
type is visible.

This also fixes a debug info quality issue: calls to isCompleteType do not
trigger the emission of debug information for a type in limited-debug-info
mode. This allows us to avoid emitting debug information for type definitions
in more cases where we believe it is safe to do so.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 22:40:25 +00:00
Richard Smith e11f410f5c Wire a SourceLocation into IsDerivedFrom and move the RequireCompleteType call
for the derived class into it. This is mostly just a cleanup, but could in
principle be a bugfix if there is some codepath that reaches here and didn't
previously require a complete type (I couldn't find any such codepath, though).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256037 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 21:45:41 +00:00
Richard Smith 222a971bb7 Preserve source location information for qualified names used in a constructor
initializer list to name a base class. Patch by Shahms King!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255420 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12 02:17:54 +00:00
Ekaterina Romanova 34a3e1fd8e Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.
For PS4, generate explicit import for anonymous namespaces and mark it by DW_AT_artificial attribute.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255281 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10 18:52:50 +00:00
Richard Smith c0b5b91dff PR25731: namespace alias declarations can appear at block scope; ensure that we
do scope-based lookup when looking for redeclarations of them. Add some related
missing checks for the scope-based redeclaration lookup: properly filter the
list of found declarations to match the scope, and diagnose shadowing of a
template parameter name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254663 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03 23:24:04 +00:00
Richard Smith b795ce04a7 [modules] Fix some more cases where we used to reject a conflict between two
declarations that are not simultaneously visible, and where at least one of
them has internal/no linkage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253283 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 03:02:41 +00:00
Craig Topper ee5949e86b Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-15 02:31:46 +00:00
Richard Smith f1b82542b7 [modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:

 * It is visible (not in a module, or in an imported module), or
 * We're doing redeclaration lookup and it's externally-visible, or
 * We're doing typo correction and looking for unimported decls.

We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.

This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on).  It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).

This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 22:19:45 +00:00
Davide Italiano 6f286e5ce1 [SemaDeclCXX] Use isTemplateParamScope() rather than accessing raw bits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252793 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11 20:06:35 +00:00
David Majnemer 0b4fbcdc84 [Sema] Remove an unreachable llvm_unreachable
No functionality change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250935 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 19:48:47 +00:00
Angel Garcia Gomez d162035b9b Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez e83bf34da9 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250822 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-20 12:52:55 +00:00
Craig Topper a0d8b00ee9 SourceRanges are small and trivially copyable, don't them by reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249259 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-04 04:53:55 +00:00
David Majnemer 20061ec162 [Sema] Don't crash when friending an unqualified templated constructor
Unqualified templated constructors cannot be friended and our lack of a
diagnostic led to violated invariants.  Instead, raise a diagnostic when
processing the friend declaration.

This fixes PR20251.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248953 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 22:07:43 +00:00
Kaelyn Takata 3e3844fd5a Don't correct non-class using declarations to class members.
Such declarations would be invalid anyway, and trying to make the
correction will lead to a crash. Fixes PR 24781.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248928 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 18:23:35 +00:00
Richard Smith 00bec9358b [modules] A using-declaration doesn't introduce a new entity, just a new name
for an existing entity, and as such a using-declaration doesn't need to
conflict with a hidden entity (nor vice versa).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247654 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15 01:28:55 +00:00
Aaron Ballman e2415b5e4b Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.
This corresponds to the CERT secure coding rule ERR53-CPP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-01 14:49:24 +00:00
Richard Smith 578238609c PR24612: Don't bail out of checking a constexpr function before checking
whether it can ever produce a constant expression in the case where it has a
void return type and no return statements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246347 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 22:33:53 +00:00
Hans Wennborg 6cc4f84bf4 Delay emitting members of dllexport classes until the class is fully parsed (PR23542)
This enables Clang to correctly handle code such as:

  struct __declspec(dllexport) S {
    int x = 42;
  };

where it would otherwise error due to trying to generate the default
constructor before the in-class initializer for x has been parsed.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245139 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-15 01:18:16 +00:00
Benjamin Kramer af49942c7c [AST] Turn the callbacks of lookupInBases and forallBases into a function_ref
This lets us pass functors (and lambdas) without void * tricks. On the
downside we can't pass CXXRecordDecl's Find* members (which are now type
safe) to lookupInBases directly, but a lambda trampoline is a small
price to pay. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-25 15:07:25 +00:00
Aaron Ballman e3a382cc11 Silence a -Wtype-limits warning; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 13:36:07 +00:00
Davide Italiano 90b02d5f5f [Sema] Make an assertion stricter.
We now check for the exact range of IdealIndex.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242652 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-19 22:07:14 +00:00
Davide Italiano 915c15b03a [Sema] Refactor Sema::ImplicitExceptionSpecification::CalledDecl
This (hopefully) brings more clarity. No functional changes (intended).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242483 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 22:37:54 +00:00
Benjamin Kramer 247b5bd74b Switch users of the 'for (StmtRange range = stmt->children(); range; ++range)‘ pattern to range for loops.
The pattern was born out of the lack of range-based for loops in C++98
and is somewhat obscure. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02 21:03:14 +00:00
Richard Smith e4090833ea Rework parsing of pure-specifiers. Perform the grammar matching and
disambiguation in the parser rather than trying to do it in Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241032 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-30 01:28:56 +00:00
Alexander Kornienko 8ca7705aa3 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 23:07:51 +00:00
Alexander Kornienko ac58acc7f2 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 09:47:44 +00:00
David Majnemer dd10c847c6 [MS Compatibility] Handle cleanups we create for a ctor closure
This fixes PR23801.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239503 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-11 02:38:06 +00:00
Hans Wennborg a1e12412ad Enable DLL attribute propagation on explicit instantiation definitions (PR23770)
This is a follow-up to r225570 which enabled adding DLL attributes when a
class template goes from explicit instantiation declaration to explicit
instantiation definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239375 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-09 00:39:09 +00:00
Hans Wennborg cde97fa8dc Enable propagation of dll attributes to previously instantiated base class templates in some cases
It is safe to add a dll attribute if the base class template previously only had
an explicit instantiation declaration, or was implicitly instantiated.

I both those cases, the members would not have been codegenned yet. In the case
of explicit instantiation declaration this is natural, and for implicit
instantiations, codegen is deferred (see r225570).

This is work towards fixing PR23770.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239373 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-09 00:39:03 +00:00
Hans Wennborg 81f94a30af Narrow the -Wunsupported-dll-base-class-template warning.
Don't warn about not being able to propagate dll attribute to a base class template
when that base already has a different attribute.

MSVC doesn't actually try to do this; the first attribute that was propagated
takes precedence, so Clang is already doing the right thing and there's no
need to warn.

(This is a step towards fixing PR21718.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239372 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-09 00:38:56 +00:00
Hans Wennborg 689569bde0 clang-cl: Handle dll attributes in explicit class template specialization definitions (PR23667)
Previously, we wouldn't call checkDLLAttribute() after the class template
specialization definition if the class template was already instantiated
by an explicit class template specialization declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238266 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 00:06:45 +00:00
David Majnemer e3d035d044 [Sema] Don't crash on out-of-line virtual constexpr functions
The method wasn't an overrider but didn't have 'virtual' textually
written because our CXXMethodDecl was an out-of-line definition.  Make
sure we use the canonical decl instead.

This fixes PR23629.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237999 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 05:49:41 +00:00
Richard Smith 399b8bf979 [modules] Support merging a parsed default function/template argument with an imported but hidden one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237814 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 17:50:35 +00:00
David Majnemer 35ec179e2b Give isCompatibleWithMSVC a better interface
We now use an enum which maps the marketing name (almost always a year)
to the major version number.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236967 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-11 03:57:49 +00:00
David Majnemer 241d45714d [MS ABI] Import move assignment operators
MSVC 2015 changed behavior from 2013; it imports move assignment
operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236966 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-11 03:00:22 +00:00
Richard Smith c636cda499 PR23373: A defaulted union copy constructor that is not trivial must still be
emitted as a memcpy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236142 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 19:26:57 +00:00
Hans Wennborg 26a663ab48 Don't dllimport/export class members with internal linkage (PR23308)
For example, a function taking a parameter with internal linkage will
itself have internal linkage since it cannot be called outside the
translation unit.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235471 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-22 04:05:17 +00:00
Reid Kleckner 5283883125 Use the most recent previous decl to check if inline is added after a definition
This affects this test case:
  void foo();
  template <typename T> class C {
    friend inline void foo();
  };
  inline void foo() {}
  C<int> c;

Here, we instantiate the foo friend decl and add it to foo's redecl
chain. However, our previous decl pointer happens to reference the first
declaration of foo, which is not marked inline. When we check to see if
foo was already defined, we implicitly search all previous decls. We
should do the same for the inline check, instead of just checking this
particular previous decl.

Reviewers: rsmith

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234374 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08 00:04:47 +00:00
Richard Smith fb6b29821a Minor simplification: do typo-correction before handling inheriting
constructors, instead of having the typo-correction code also dispatch to the
inheriting constructor special case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-01 19:31:06 +00:00
Benjamin Kramer 3e68ff59bb [Sema] Implement DR777
A parameter pack after a default argument is now valid.

PR23029.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 13:58:41 +00:00