Commit Graph

786 Commits

Author SHA1 Message Date
Aaron Ballman b3ce54c645 __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension.
Note: __declspec is also temporarily enabled when compiling for a CUDA target because there are implementation details relying on __declspec(property) support currently. When those details change, __declspec should be disabled for CUDA targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238238 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 19:44:52 +00:00
Aaron Ballman 13c534b9fb Refactored some common functionality into MaybeParseMicrosoftDeclSpecs; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237835 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 20:58:33 +00:00
Richard Smith 93517ddb4a [modules] Suport for merging a parsed enum definition into an existing imported but not visible definition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236690 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-07 03:54:19 +00:00
Jordan Rose c00065b76e Batch up access-related diagnostics on enum constants until the whole enum is parsed.
That way we can take any trailing availability attributes into account.

rdar://problem/20713550

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236241 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 17:20:30 +00:00
David Majnemer 8267c2ef38 [MS ABI] Correctly associate align attrs before the class-key
__declspec(align(...)) is unlike all other attributes in that it is not
applied to a variable if it appears before the class-key.  If the
tag in question isn't part of a variable declaration, it is not ignored.

Instead, the alignment attribute is applied to the tag.

This fixes PR18024.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235272 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-19 07:53:29 +00:00
Benjamin Kramer 2d7fe73daa [parser] Push _Atomic locs through DeclaratorChunk.
Otherwise it stays uninitialized with potentially catastrophic results.
Found by afl-fuzz.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233494 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 16:42:06 +00:00
Ehsan Akhgari a0cadf2f4b Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints
Summary: Follow-up to the fix of PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233161 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 00:53:33 +00:00
Ehsan Akhgari e68a179790 Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233160 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 00:53:27 +00:00
Ehsan Akhgari b82932c19b Revert "Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints"
This reverts commit 2131e63e2f.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233074 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 13:25:26 +00:00
Ehsan Akhgari 6694b30bcc Revert "Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints"
This reverts commit 49079d4596.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233073 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 13:25:23 +00:00
Ehsan Akhgari 49079d4596 Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints
Summary: Follow-up to the fix of PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233070 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 13:02:50 +00:00
Ehsan Akhgari 2131e63e2f Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233069 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 13:02:47 +00:00
Benjamin Kramer dcf67b2978 Use Sema's PrintingPolicy when diagnosing DeclSpecs.
Sema overrides ASTContext's policy on the first emitted diagnostic
(doesn't matter if it's ignored or not). This means changing the order
of diagnostic emission in Sema suddenly changes the text of diagnostic
emitted from the parser.

In the test case -Wmissing-prototypes (ignored) was the culprit, use
'int main' to suppress that warning so we see when this regresses.
Also move it into Sema/ as it's not testing any C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232039 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 14:28:38 +00:00
David Blaikie a9ee4553b8 Simplify boolean expressions in clang with clang-tidy
Patch by Richard (legalize at xmission dot com).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231619 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-09 02:02:07 +00:00
Nico Weber 6f21bc5316 Wrap to 80 columns. No behavior change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229637 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 04:53:03 +00:00
Nico Weber aad6cdd1bc Don't crash on `struct ::, struct ::` (and the same for enums).
The first part of that line doesn't parse correctly and ParseClassSpecifier() for
some reason skips to tok::comma to recover, and then
ParseDeclarationSpecifiers() sees the next struct and calls
ParseClassSpecifier() again with the same DeclSpec object.

However, the first call already called ActOnCXXGlobalScopeSpecifier() on the
DeclSpec's CXXScopeSpec, and sema gets confused when this gets called again.

As a fix, let ParseClassSpecifier() (and ParseEnumSpecifier()) call
ParseOptionalCXXScopeSpec() with a temporary CXXScopeSpec object, and only
copy it into the DeclSpec if things work out.  (This is also how all the other
functions that set the DeclSpec's TypeSpecScope set it.)

Found by SLi's bot.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229288 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-15 07:26:13 +00:00
Francisco Lopes da Silva 40785b0b94 Initial support for C++ parameter completion
The improved completion in call context now works with:

 - Functions.
 - Member functions.
 - Constructors.
 - New expressions.
 - Function call expressions.
 - Template variants of the previous.

There are still rough edges to be fixed:

 - Provide support for optional parameters.         (fix known)
 - Provide support for member initializers.         (fix known)
 - Provide support for variadic template functions. (fix unknown)
 - Others?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 16:24:11 +00:00
Richard Smith 73e3217e76 Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226067 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 00:48:52 +00:00
David Majnemer f233cba7f0 Parse: Switch to using EOF tokens for late parsed attributes
The EOF token injection technique is preferable to using
isBeforeInTranslationUnit to determine whether or not additional cleanup
is needed.  I don't have an example off-hand that requires it but it is
nicer nonetheless.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225776 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 08:35:24 +00:00
David Majnemer 8f0f848a5e Parse: Don't crash if missing an initializer expression
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225768 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 05:28:24 +00:00
David Majnemer 4c9b4e89d2 Parse: Further simplify ParseLexedMethodDeclaration
No functionality change intended, just moving code around to make it
simpler.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225763 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 04:20:57 +00:00
Bill Seurer b2a190951f [PowerPC]To provide better compatibility with gcc I added the __bool keyword to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example:
vector bool char v_bc;
vector __bool char v___bc;

clang already supported vector/__vector and pixel/__pixel but was missing __bool.

http://llvm.org/bugs/show_bug.cgi?id=19220

For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html

http://reviews.llvm.org/D6882


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225664 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 19:35:51 +00:00
David Majnemer 614938ef44 Parse: Get rid of tok::cxx_defaultarg_end, use EOF instead
I added setEofData/getEofData to solve this sort of problem back in
r224505.  Use the Param's decl to tell us if this is *our* EOF token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225619 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 05:17:40 +00:00
David Majnemer 2e4bd4b597 Parse: __attribute__((keyword)) shouldn't error
Weird constructs like __attribute__((inline)) or
__attibute__((typename)) should result in warnings, not errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225118 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-03 19:41:00 +00:00
David Majnemer 1df588e253 Parse: Don't crash when 'typename' shows up in an attribute
isDeclarationSpecifier performs error recovers which jostles the token
stream.  Specifically, TryAnnotateTypeOrScopeToken will end up consuming
a typename token which will confuse the attribute parsing machinery as
we no-longer have something identifier-like.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224903 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-28 22:28:32 +00:00
Richard Smith 4dbf06c23f PR21969: Improve diagnostics for a conversion function that has any pieces of a
declared return type (including a trailing-return-type in C++14).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224561 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 02:07:47 +00:00
Kaelyn Takata 0ef7967c69 Correct delayed typos in the operand to typeof expressions.
Fixes PR21947.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 01:28:40 +00:00
Reid Kleckner 06b9847147 Diagnose function template definitions inside functions
The parser can only be tricked into parsing a function template
definition by inserting a typename keyword before the function template
declaration. This used to make us crash, and now it's fixed.

While here, remove an unneeded boolean parameter from ParseDeclGroup.
This boolean always corresponded to non-typedef declarators at file
scope. ParseDeclGroup already has precise diagnostics for the function
definition typedef case, so we can let that through.

Fixes PR21839.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 23:16:32 +00:00
Nico Rieck ee66c4c12a Parse qualifiers after comma in declarator lists as a Microsoft extension
MSVC parses and ignores these with a warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223413 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 23:31:08 +00:00
Faisal Vali 61f9a779a8 Fix PR21684 - Ellipsis following an 'auto' parameter sans name/ID
should indicate a c++ parameter pack not a c-variadic.

int i = [](auto...) { return 0; }(); // OK now.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223357 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 12:40:21 +00:00
Anastasia Stulova 08c258670c [OpenCL] Generic address space has been added in OpenCL v2.0.
To support it in the frontend, the following has been added:  
- generic address space type attribute;
- documentation for the OpenCL address space attributes;
- parsing of __generic(generic) keyword;
- test code for the parser and diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222831 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 14:10:06 +00:00
Kaelyn Takata 7bd108b7fc Enable ActOnIdExpression to use delayed typo correction for non-C++ code
when calling DiagnoseEmptyLookup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222551 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-21 18:48:04 +00:00
Richard Smith 4363fafac9 PR21565: Further refine the conditions for enabling eager parsing of
std::X::swap exception specifications (allowing parsing of non-conforming code
in libstdc++). The old conditions also matched the functions in MSVC's STL,
which were relying on deferred parsing here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222471 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 22:32:11 +00:00
Kaelyn Takata b11b40a67e Wire up delayed typo correction to DiagnoseEmptyLookup and set up
Sema::ActOnIdExpression to use the new functionality.

Among other things, this allows recovery in several cases where it
wasn't possible before (e.g. correcting a mistyped static_cast<>).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222464 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 22:06:40 +00:00
David Blaikie f8fdd74444 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 07:49:47 +00:00
Richard Smith c806720c55 PR21565 Add an egregious hack to support broken libstdc++ headers that declare
a member named 'swap' and then expect unqualified lookup for the name 'swap' in
its exception specification to find anything else.

Without delay-parsed exception specifications, this was ill-formed (NDR) by
[basic.scope.class]p1, rule 2. With delay-parsed exception specifications, the
call to 'swap' unambiguously finds the function being declared, which then
fails because the arguments don't work for that function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221955 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 00:37:55 +00:00
Richard Smith 773d19cce4 PR21437, final part of DR1330: delay-parsing of exception-specifications. This
is a re-commit of Doug's r154844 (modernized and updated to fit into current
Clang).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221918 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 20:01:57 +00:00
Richard Smith 82019ed873 Improve diagnostics if _Noreturn is placed after a function declarator. (This sometimes happens when a macro is used that expands to either the GNU noreturn attribute or _Noreturn.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221630 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-10 21:10:32 +00:00
Aaron Ballman 132515f645 Updated the wording for a diagnostic to be more grammatically correct, and use a %select. Also ensure that nested namespace definitions are diagnosed properly. Both changes are motivated by post-commit feedback from r221580.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221581 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-08 17:07:15 +00:00
Aaron Ballman 079c143c3e [c++1z] Support for attributes on namespaces and enumerators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221580 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-08 15:33:35 +00:00
Fariborz Jahanian 366198b99a Patch for small addition to availability attribute.
This is to accept "NA" in place of vesion number for availability
attribute. Used on introduced=NA to mean unavailable
and deprecated=NA to mean nothing (not deprecated).
rdar://18804883


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221417 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05 23:58:55 +00:00
Richard Smith 57c820fc40 PR21367: Don't accept rvalue references as an extension in C++98 mode if we're in a new-type-id or conversion-type-id, since those things can legitimately be followed by a binary && operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220785 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28 16:55:02 +00:00
Reid Kleckner cb348a9ab7 Add frontend support for __vectorcall
Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220573 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 17:42:17 +00:00
Rafael Espindola c886ae8062 Remove unused StmtVector& parameters from declaration parsing functions.
Patch by Eelis van der Weegen!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220387 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 14:27:08 +00:00
Hal Finkel a2be46b72e Add RestrictQualifierLoc to DeclaratorChunk::FunctionTypeInfo
Clang supports __restrict__ as a function qualifier, but
DeclaratorChunk::FunctionTypeInfo lacked a field to track the qualifier's
source location (as we do with volatile, etc.). This was the subject of a FIXME
in GetFullTypeForDeclarator (in SemaType.cpp). This should also prove useful as
we add more warnings regarding questionable uses of the restrict qualifier.

There is no significant functional change (except for an improved source range
associated with the err_invalid_qualified_function_type diagnostic fixit
generated by GetFullTypeForDeclarator).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220215 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 17:32:04 +00:00
Fariborz Jahanian 835452b27a Patch to wrap up '_' as separator in version numbers
in availability attribute by preserving this info.
in VersionTuple and using it in pretty printing of attributes
and yet using '.' as separator when diagnosing unavailable 
message calls. rdar://18490958


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219124 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 16:46:02 +00:00
Fariborz Jahanian e4b6b088fe Add comment about separators must match in
version numbers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218993 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-03 17:21:12 +00:00
Fariborz Jahanian 328cf9877b Diagnose mixed use of '_' and '.' as version
separators in my previous patch. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218895 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 17:57:26 +00:00
Fariborz Jahanian 6c083aa6a8 Patch to accept '_' in addition to '.' as version
number separator in "availability" attribute.
rdar://18490958


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218884 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 16:39:45 +00:00
Nikola Smiljanic 7159053ff3 -ms-extensions: Implement __super scope specifier (PR13236).
We build a NestedNameSpecifier that records the CXXRecordDecl in which
__super appeared. Name lookup is performed in all base classes of the
recorded CXXRecordDecl. Use of __super is allowed only inside class and
member function scope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218484 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-26 00:28:20 +00:00