Commit Graph

11357 Commits

Author SHA1 Message Date
Alexey Bataev 9c2e8ee72f [OPENMP] Parsing and sema analysis for 'omp task' directive.
llvm-svn: 212804
2014-07-11 11:25:16 +00:00
Reid Kleckner 675d438e23 Return a FixItHint instead of taking a diagnostic builder
Addressing review comments from r212784.

llvm-svn: 212786
2014-07-11 00:16:51 +00:00
Reid Kleckner 0902a51baf MSVC compat: Allow lookup of friend types in enclosing namespaces
The relevant portion of C++ standard says [namespace.memdef]p3:

  If the name in a friend declaration is neither qualified nor a
  template-id and the declaration is a function or an
  elaborated-type-specifier, the lookup to determine whether the entity
  has been previously declared shall not consider any scopes outside the
  innermost enclosing namespace.

MSVC does not implement that rule for types.  If there is a type in an
enclosing namespace, they consider an unqualified tag declaration with
the same name to be a redeclaration of the type from another namespace.

Implementing compatibility is a simple matter of disabling our
implementation of this rule for types, which was added in r177473.

Reviewers: rsmith

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

llvm-svn: 212784
2014-07-10 23:44:52 +00:00
Richard Smith 95b83e917e PR20256: don't accidentally instantiate non-dependent default-initialization as
value-initialization.

llvm-svn: 212764
2014-07-10 20:53:43 +00:00
David Majnemer 837d5de330 Sema: Allow aliases to have incomplete type
gcc supports this behavior and it is pervasively used inside the Linux
kernel.

Note that both gcc and clang will reject code that attempts to do this
in a C++ language mode.

This fixes PR17998.

llvm-svn: 212631
2014-07-09 17:15:52 +00:00
Nikola Smiljanic 1c1256830d Fix typos.
llvm-svn: 212589
2014-07-09 05:42:35 +00:00
Nico Weber 9709ebfaf0 rewrap to 80 cols, no behavior change
llvm-svn: 212578
2014-07-08 23:54:25 +00:00
Nico Weber 3c68ee95ca rewrap to 80 cols, no behavior change
llvm-svn: 212574
2014-07-08 23:46:20 +00:00
Reid Kleckner fd068271e6 MS compat: Allow lookup of types from dependent bases in functions
If we want to resolve the remaining FIXMEs here, we probably want to
extend the main lookup mechanism to perform lookup into dependent bases,
but we would have to tread lightly.  Adding more name lookup has major
impact on compile time.

If we did extend the main mechanism, we would add a flag to LookupResult
that allows us to find names from dependent base classes where the base
is a specialization of a known template.  The final LookupResult would
still return LookupResult::NotFoundInCurrentInstantiation, but it would
have a collection of Decls.  If we find a real lookup result, we would
clear the flag and the existing lookup results and begin accumulating
only real lookup results.

We would structure the lookup as a secondary lookup between normal
lookup and typo correction for normal compilation, but for MSVC
compatibility mode, we would always enable this extra lookup into
dependent bases.

llvm-svn: 212566
2014-07-08 21:35:03 +00:00
Reid Kleckner 1ba38f8879 Allow more lookup of types in dependent base classes
MSVC appears to perform name lookup into dependent base classes when the
dependent base class has a known primary template.  This allows them to
know whether some unqualified ids are types or not, which allows them to
parse more class templates without typename keywords.

We can do the same thing when type name lookup fails, and if we find a
single type decl in one of our dependent base classes, recover as though
the user wrote 'typename MyClass::TypeFromBase'.

This allows us to parse some COM smart pointer classes in wrl/client.h
from the Windows 8 SDK.

Reviewers: rsmith

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

llvm-svn: 212561
2014-07-08 20:05:48 +00:00
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
Richard Smith 1133085461 PR20227: materialize a temporary when dynamic_casting a class prvalue to a
reference type.

llvm-svn: 212551
2014-07-08 17:25:14 +00:00
Alexey Bataev 84d0b3efee [OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.
llvm-svn: 212516
2014-07-08 08:12:03 +00:00
Alp Toker d920b7fc85 Rename static function to better describe its purpose
llvm-svn: 212502
2014-07-08 00:02:05 +00:00
Alexey Bataev 4acb859fbd [OPENMP] Added initial support for 'omp parallel for'.
llvm-svn: 212453
2014-07-07 13:01:15 +00:00
Alp Toker 03376dc2c5 Switch over a few uses of param_begin() to parameters()
llvm-svn: 212442
2014-07-07 09:02:20 +00:00
Nico Weber 9b982078e9 Add an AST node for __leave statements, hook it up.
Codegen is still missing (and I won't work on that), but __leave is now
as implemented as __try and friends.

llvm-svn: 212425
2014-07-07 00:12:30 +00:00
Nico Weber eb61d4d7c2 Sema: Check that __leave is contained in a __try block.
Give scope a SEHTryScope bit, set that in ParseSEHTry(), and let Sema
walk the scope chain to find the SEHTry parent on __leave statements.
(They are rare enough that it seems better to do the walk instead of
giving Scope a SEHTryParent pointer -- this is similar to AtCatchScope.)

llvm-svn: 212422
2014-07-06 22:53:19 +00:00
Nico Weber c7d0596429 Add parser support for __leave (sema and onward still missing).
llvm-svn: 212421
2014-07-06 22:32:59 +00:00
Fariborz Jahanian a99119a18b Make a small crash preventing change.
llvm-svn: 212291
2014-07-03 21:06:20 +00:00
Yi Kong 4efadfb0b0 [ARM] Implement ISB memory barrier intrinsic
Adds support for __builtin_arm_isb. Also corrects DSB and ISB instructions
modelling by adding has-side-effects property.

llvm-svn: 212277
2014-07-03 16:01:25 +00:00
Nico Weber 5752ad0abc Address review feedback for r212238.
Also, forgot to say in the commit message of r212238: Library authors will
see a warning about this issue if they build with -Wsystem-headers.

llvm-svn: 212243
2014-07-03 00:38:25 +00:00
Nico Weber bcb70eee1a Enable clang to continue to parse libstdc++4.6 and stlport after r210091.
r210091 made initialization checking more strict in c++11 mode. LWG2193 is
about changing standard libraries to still be valid under these new rules,
but older libstdc++ (e.g. libstdc++4.6 in -D_GLIBCXX_DEBUG=1 mode, or stlport)
do not implement that yet.  So fall back to the C++03 semantics for container
classes in system headers below the std namespace.

llvm-svn: 212238
2014-07-02 23:51:09 +00:00
Tim Northover 3acd6bd0b6 ARM: add support for v8 ldaex/stlex builtins.
ARMv8 adds (to both AArch32 and AArch64) acquiring and releasing
variants of the exclusive operations, in line with the C++11 memory
model.

This adds support for two new intrinsics to expose them to C & C++
developers directly: __builtin_arm_ldaex and __builtin_arm_stlex, in
direct analogy with the versions with no implicit barrier.

rdar://problem/15885451

llvm-svn: 212175
2014-07-02 12:56:02 +00:00
Alp Toker f5b107940a Make FunctionDecl::getReturnTypeSourceRange() support non-builtin types
Also document that the function is a "best-effort" facility to extract source
ranges from limited AST type location info.

llvm-svn: 212174
2014-07-02 12:55:58 +00:00
Alp Toker 70fc29ca86 Don't accept qualified 'int' main return types in C++ or standard C mode
C++ [basic.start.main]p1: "It shall have a return type of type int"

ISO C is also clear about this, so only accept 'int' with qualifiers in GNUMode
C.

llvm-svn: 212171
2014-07-02 07:07:20 +00:00
Richard Trieu dadefde294 Prevent Clang from crashing on template code.
Fixes PR20110, where Clang hits an assertion failure when it expects that the
sub-expression of a bit cast to pointer to also be a pointer, but gets a value
instead.

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

llvm-svn: 212160
2014-07-02 04:39:38 +00:00
Alexey Bataev 41b9732f68 [OPENMP] Fixed error message reporting for nesting of regions
llvm-svn: 212156
2014-07-02 03:04:53 +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
Alexey Bataev 18eb25e85b [OPENMP] Added table with allowed nesting info for OpenMP regions (per request from Samuel F Antao).
llvm-svn: 212034
2014-06-30 10:22:46 +00:00
Alexey Bataev aca7fcf276 Using of variable length arrays in captured statements and OpenMP constructs.
Differential Revision: http://reviews.llvm.org/D4067

llvm-svn: 212010
2014-06-30 02:55:54 +00:00
Alp Toker 034bbd5db7 Extract an isReservedName() function
We'll want to share the implementation if anything else decides to check
for reserved names in future, so make this little snippet of code more
discoverable.

Also remove the __va_list_tag and __builtin_va_list special-case
checks. They're leftovers from before when the reserved name logic was
added.

No change in functionality.

llvm-svn: 212006
2014-06-30 01:33:53 +00:00
Richard Trieu c1888e0c6e Extend -Wtautological-undefined-compare and -Wundefined-bool-conversion to
trigger on taking the address of a reference that is returned from a function
call.

llvm-svn: 211989
2014-06-28 23:25:37 +00:00
Craig Topper e3d2ecbe86 Import MutableArrayRef into clang namespace.
llvm-svn: 211988
2014-06-28 23:22:33 +00:00
Craig Topper 00bbdcf9b3 Remove llvm:: from uses of ArrayRef.
llvm-svn: 211987
2014-06-28 23:22:23 +00:00
Reid Kleckner 5fb5b12d48 Extend -Wdynamic-class-memaccess to records containing dynamic classes
Reviewers: rtrieu

Subscribers: cfe-commits

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

llvm-svn: 211972
2014-06-27 23:58:21 +00:00
Alexey Bataev bae9a793fd [OPENMP] Parsing and sema analysis for 'copyprivate' clause.
llvm-svn: 211886
2014-06-27 10:37:06 +00:00
Fariborz Jahanian 53f867ac45 Objective-C ARC. Provide diagnostic and fix-it
when casting a retainable object to a objc_bridge_related
CF type with the suggestion of applying the method
specified in the bridging attribute to the object.
// rdar://15932435

llvm-svn: 211807
2014-06-26 21:22:16 +00:00
Alexey Bataev d1e40fbfe1 [OPENMP] Initial parsing and sema analysis for 'single' directive.
llvm-svn: 211774
2014-06-26 12:05:45 +00:00
Alexey Bataev 1e0498a92d [OPENMP] Initial parsing and sema analysis for 'section' directive.
llvm-svn: 211767
2014-06-26 08:21:58 +00:00
David Majnemer 07910d6ab5 Sema: Allow dllimport entities in template args for mingw
Previously dllimport variables inside of template arguments relied on
not using the C++11 codepath when -fms-compatibility was set.

While this allowed us to achieve compatibility with MSVC, it did so at
the expense of MingW.

Instead, try to use the DeclRefExpr we dig out of the template argument.
If it has the dllimport attribute, accept it and skip the C++11
null-pointer check.

llvm-svn: 211766
2014-06-26 07:48:46 +00:00
Craig Topper 7e0daca110 Convert some function arguments to use ArrayRef.
llvm-svn: 211764
2014-06-26 04:58:53 +00:00
Craig Topper 9d5583ef0a Convert StringLiteralParser constructor to use ArrayRef instead of a pointer and count.
llvm-svn: 211763
2014-06-26 04:58:39 +00:00
Hans Wennborg 82dd877e8a Don't allow dllimport variables in constant initializers
This is a follow-up to David's r211677. For the following code,
we would end up referring to 'foo' in the initializer for 'arr',
and then fail to link, because 'foo' is dllimport and needs to be
accessed through the __imp_?foo.

  __declspec(dllimport) extern const char foo[];
  const char* f() {
    static const char* const arr[] = { foo };
    return arr[0];
  }

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

llvm-svn: 211736
2014-06-25 22:19:48 +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
Serge Pavlov a826147eef Fix treatment of types defined in function prototype
Types defined in function prototype are diagnosed earlier in C++ compilation.
They are put into declaration context where the prototype is introduced. Later on,
when FunctionDecl object is created, these types are moved into the function context.

This patch fixes PR19018 and PR18963.

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

llvm-svn: 211718
2014-06-25 17:09:41 +00:00
Alexey Bataev d3f8dd2d15 [OPENMP] Initial support for 'sections' directive.
llvm-svn: 211685
2014-06-25 11:44:49 +00:00
Alexey Bataev abfc069d6c [OPENMP] OMPSimdDirective and OMPForDirective: added initialization for CollapsedNum member.
llvm-svn: 211672
2014-06-25 06:52:00 +00:00
Alexey Bataev df9b15905f [OPENMP] Improved code and replaced struct by lambda.
llvm-svn: 211660
2014-06-25 04:09:13 +00:00
Hans Wennborg 5e64528195 MS ABI: Ignore dll attributes on partial template specializations
llvm-svn: 211648
2014-06-24 23:57:13 +00:00