Commit Graph

2033 Commits

Author SHA1 Message Date
Dmitri Gribenko 139474d498 ArrayRef'ize Sema::ActOnMemInitializer
llvm-svn: 181565
2013-05-09 23:51:52 +00:00
Richard Smith 21b3ab43e1 C++1y n3648: parse and reject init-captures for now.
llvm-svn: 181553
2013-05-09 21:36:41 +00:00
Reid Kleckner e43f0fea15 Forward #pragma comment(lib/linker) through as flags metadata
Summary:
Most of this change is wiring the pragma all the way through from the
lexer, parser, and sema to codegen.  I considered adding a Decl AST node
for this, but it seemed too heavyweight.

Mach-O already uses a metadata flag called "Linker Options" to do this
kind of auto-linking.  This change follows that pattern.

LLVM knows how to forward the "Linker Options" metadata into the COFF
.drectve section where these flags belong.  ELF support is not
implemented, but possible.

This is related to auto-linking, which is http://llvm.org/PR13016.

CC: cfe-commits

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

llvm-svn: 181426
2013-05-08 13:44:39 +00:00
Reid Kleckner 002562a8c1 Move PragmaCommentHandler to lib/Parse in preparation for calling Sema
Summary:
No functionality change.  The existing tests for this pragma only verify
that we can preprocess it.

Reviewers: rsmith

CC: cfe-commits

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

llvm-svn: 181246
2013-05-06 21:02:12 +00:00
Dmitri Gribenko 78852e91c8 Replace 'MultiExprArg()' with 'None'
llvm-svn: 181166
2013-05-05 20:40:26 +00:00
Dmitri Gribenko 44ebbd5436 Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef constructor from None
Patch by Robert Wilhelm.

llvm-svn: 181139
2013-05-05 00:41:58 +00:00
Aaron Ballman 444eb6e23c Properly parsing __declspec(safebuffers), though there is no semantic hookup. For more information about safebuffers, see MSDN: http://msdn.microsoft.com/en-us/library/dd778695(v=vs.110).aspx
llvm-svn: 181123
2013-05-04 16:58:37 +00:00
Richard Smith 01518fa77a Separate out and special-case the diagnostic for 'auto' in a
conversion-type-id, in preparation for this becoming valid in c++1y mode.
No functionality change; small diagnostic improvement.

llvm-svn: 181089
2013-05-04 01:26:46 +00:00
Douglas Gregor b4eadc34e1 <rdar://problem/13806270> A template argument list is a constant-evaluated context.
llvm-svn: 181076
2013-05-03 23:44:54 +00:00
Ben Langmuir 37943a7af8 Move CapturedStmt parameters to CapturedDecl
Move the creation of CapturedStmt parameters out of CodeGen and into
Sema, making it easier to customize the outlined function. The
ImplicitParamDecls are stored in the CapturedDecl using an
ASTContext-allocated array.

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

llvm-svn: 181043
2013-05-03 19:00:33 +00:00
John McCall f413f5ed44 Move parsing of identifiers in MS-style inline assembly into
the actual parser and support arbitrary id-expressions.

We're actually basically set up to do arbitrary expressions here
if we wanted to.

Assembly operands permit things like A::x to be written regardless
of language mode, which forces us to embellish the evaluation
context logic somewhat.  The logic here under template instantiation
is incorrect;  we need to preserve the fact that an expression was
unevaluated.  Of course, template instantiation in general is fishy
here because we have no way of delaying semantic analysis in the
MC parser.  It's all just fishy.

I've also fixed the serialization of MS asm statements.

This commit depends on an LLVM commit.

llvm-svn: 180976
2013-05-03 00:10:13 +00:00
Douglas Gregor d2472d4cdb Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align((Align)))) char storage[Size];
 };

while this would parse as a "parameter name" 'Align':

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align(Align))) char storage[Size];
 };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

 template<unsigned Size, unsigned Align>
 class my_aligned_storage
 {
   __attribute__((align)) char storage[Size];
 };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180973
2013-05-02 23:25:32 +00:00
Douglas Gregor 33ebfe36e5 Revert r180970; it's causing breakage.
llvm-svn: 180972
2013-05-02 23:15:45 +00:00
Douglas Gregor 44dff3f2dc Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align((Align)))) char storage[Size];
  };

while this would parse as a "parameter name" 'Align':

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align(Align))) char storage[Size];
  };

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

  template<unsigned Size, unsigned Align>
  class my_aligned_storage
  {
    __attribute__((align)) char storage[Size];
  };

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.

llvm-svn: 180970
2013-05-02 23:08:12 +00:00
Richard Smith 3b87038631 Fix PR15845: apparently MSVC does not support implicit int in C++ mode.
llvm-svn: 180822
2013-04-30 22:43:51 +00:00
Richard Smith 27d807cc9c Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.

llvm-svn: 180789
2013-04-30 13:56:41 +00:00
Fariborz Jahanian d56a262200 Fix a typo in a parse assert.
Patch by Alex Denisov.

llvm-svn: 180712
2013-04-29 15:35:35 +00:00
Ben Langmuir e7d7c4cfc2 Small CapturedStmt improvements
Add a CapturedStmt.h similar to Lambda.h to reduce the typing required to get
to the CapturedRegionKind enum. This also allows codegen to access this enum
without including Sema/ScopeInfo.h.

Also removes some duplicated code for capturing 'this' between CapturedStmt and
Lambda.

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

llvm-svn: 180710
2013-04-29 13:32:41 +00:00
Richard Smith c8378952fb Keep the parser's template depth up to date when parsing local templates and
late-parsed templates. Patch by Faisal Vali!

llvm-svn: 180708
2013-04-29 11:55:38 +00:00
Richard Smith 07cea1911a Properly reenter multiple contexts when parsing a late-parsed function template
within a dependent context. Patch by Will Wilson (+clang-format)!

llvm-svn: 180702
2013-04-29 08:53:40 +00:00
Dmitri Gribenko e5fde996dc ArrayRef'ize Sema::ActOnEnumBody. No functionality change.
Patch by Robert Wilhelm.

llvm-svn: 180682
2013-04-27 20:23:52 +00:00
Richard Smith 74aeef50a0 Implement C++1y decltype(auto).
llvm-svn: 180610
2013-04-26 16:15:35 +00:00
Fariborz Jahanian 46ed4d978e Objective-C parsing [qoi]: Recover gracefully with good diagnostic
when class implementation declaration adds protocol qualifier
list. // rdar://12233858

llvm-svn: 180228
2013-04-24 23:23:47 +00:00
Richard Trieu d0d87b5972 Warn that scoped enumerations are a C++11 extenstion when compiling in
C++98 mode.  This improves on the previous diagnostic message of:

error: expected identifier or '{'
llvm-svn: 180076
2013-04-23 02:47:36 +00:00
Richard Smith 034185c2f9 The 'constexpr implies const' rule for non-static member functions is gone in
C++1y, so stop adding the 'const' there. Provide a compatibility warning for
code relying on this in C++11, with a fix-it hint. Update our lazily-written
tests to add the const, except for those ones which were testing our
implementation of this rule.

llvm-svn: 179969
2013-04-21 01:08:50 +00:00
Fariborz Jahanian d5d6f3d5a2 Objective-C++: Enable passing of modern C++11 style
initialized temporaries to objc++ methods. 
// rdar://12788429

llvm-svn: 179818
2013-04-18 23:43:21 +00:00
Fariborz Jahanian 507a5f8cb3 Objective-C parsing [qoi]: Provide good recovery when
Objective-C dictionary literals has bad syntax for the
separator. // rdar://10679157

llvm-svn: 179784
2013-04-18 19:37:43 +00:00
Argyrios Kyrtzidis 71c12fb4a3 [Parser] Handle #pragma pack/align inside C structs.
Fixes PR13580. Patch by Serge Pavlov!

llvm-svn: 179743
2013-04-18 01:42:35 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

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

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Tareq A. Siraj 0de0dd4923 Parser support for #pragma clang __debug captured
This patch implements parsing ‘#pragma clang __debug’ as a first step for
implementing captured statements. Captured statements are a mechanism for
doing outlining in the AST.
see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

Currently returns StmtEmpty

Author: Andy Zhang <andy.zhang@intel.com>

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

llvm-svn: 179614
2013-04-16 18:41:26 +00:00
Douglas Gregor 012efe22bc Fix PR4296: Add parser detection/error recovery for nested functions, from Serve Pavlov!
llvm-svn: 179603
2013-04-16 16:01:32 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Richard Smith b4a9e86877 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.

llvm-svn: 179424
2013-04-12 22:46:28 +00:00
Douglas Gregor 2eb1c57b9d <rdar://problem/13540921> Fix a crasher when an Objective-C for-in loop gets a non-variable iteration declaration.
llvm-svn: 179053
2013-04-08 20:52:24 +00:00
Nico Weber 69a7914fec Make the ObjC attributes diagnostics a bit more informative.
llvm-svn: 178720
2013-04-04 00:15:10 +00:00
Nico Weber 04e213b6b6 Emit a nicer diagnostic for misplaced attributes on ObjC directives.
llvm-svn: 178670
2013-04-03 17:36:11 +00:00
Kaelyn Uhrain 989b7ca092 Give the default CorrectionCandidateCallback::ValidateCandidate some
smarts so that it doesn't approve of keywords and/or type names when it
knows (based on its flags) that those kinds of corrections are not
wanted.

llvm-svn: 178668
2013-04-03 16:59:49 +00:00
Andy Gibbs c804e08a67 Enable use of _Static_assert inside structs and unions in C11 mode (as per C11 6.7.2.1p1).
llvm-svn: 178632
2013-04-03 09:46:04 +00:00
Andy Gibbs 22e140bee4 Assert that Parser::ParseStructUnionBody is not called for C++ code.
llvm-svn: 178631
2013-04-03 09:31:19 +00:00
Fariborz Jahanian 896ae920d5 Objective-C arc [qui]. Don't issue the bridge cast
warning when doing a __bride cast in non-arc
mode (which has no retain count effect).
// rdar://13514210

llvm-svn: 178592
2013-04-02 23:48:59 +00:00
Richard Smith 1d4b2e16a2 PR15633: Note that we are EnteringContext when parsing the nested name
specifier for an enumeration. Also fix a crash-on-invalid if a non-dependent
name specifier is used to declare an enum template.

llvm-svn: 178502
2013-04-01 21:43:41 +00:00
Richard Smith 8e1ac33ec7 Support C11 _Atomic type qualifier. This is more-or-less just syntactic sugar for the _Atomic type specifier.
llvm-svn: 178210
2013-03-28 01:55:44 +00:00
Argyrios Kyrtzidis c36633c47a [Parser] Don't code-complete twice.
When we are consuming the current token just to enter a new token stream, we push
the current token in the back of the stream so that we get it again.

Unfortunately this had the effect where if the current token is a code-completion one,
we would code-complete once during consuming it and another time after the stream ended.

Fix this by making sure that, in this case, ConsumeAnyToken() will consume a code-completion
token without invoking code-completion.

rdar://12842503

llvm-svn: 178199
2013-03-27 23:58:17 +00:00
Joao Matos c9523d4f44 Implement compiler intrinsics needed for compatibility with MSVC 2012 <type_traits>.
Patch by me and Ryan Molden.

llvm-svn: 178111
2013-03-27 01:34:16 +00:00
Richard Smith 7447af48b1 Implement special-case name lookup for inheriting constructors: member
using-declarations with names which look constructor-like are interpreted as
constructor names.

llvm-svn: 177957
2013-03-26 01:15:19 +00:00
Nick Lewycky 966b19951f Try harder to be signal-safe inside our signal handler. The most prominent behavioural
difference is that we no longer clean the token before emitting it. This fixes a bug where
clang hangs in the middle of crashing because the crash handler calls malloc from inside
a crash that happened inside of free.

llvm-svn: 177919
2013-03-25 21:24:30 +00:00
Alexey Bataev a769e07232 OpenMP threadprivate directive parsing and semantic analysis
llvm-svn: 177705
2013-03-22 06:34:35 +00:00
John McCall eaef89b197 Fix a crash-on-valid where a block capture copy expression was
picking up cleanups from earlier in the statement.  Also fix a
crash-on-invalid where a reference to an invalid decl from an
enclosing scope was causing an expression to fail to build, but
only *after* a cleanup was registered from that statement,
causing an assertion downstream.

The crash-on-valid is rdar://13459289.

llvm-svn: 177692
2013-03-22 02:10:40 +00:00
Fariborz Jahanian 0b171939dc Do the error recovery for @end only.
I am not sure how much we can improve for
when a randon ObjC keyword is thrown into the
ivar decl. block. // rdar://6854840

llvm-svn: 177553
2013-03-20 18:45:49 +00:00
Fariborz Jahanian 089f39ec06 Objective-C [qoi] more gracefull recovery when
'}' is missing for the ivar declarations.
// rdar://6854840

llvm-svn: 177549
2013-03-20 18:09:33 +00:00