summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
* Parse: Don't crash when an annotation token shows up in a C++11 attrDavid Majnemer2015-01-091-3/+5
| | | | | | | It's not safe to blindly call getIdentifierInfo without checking the token is not an annotation token. llvm-svn: 225533
* Parse: Don't crash when namespace is in GNU statement exprDavid Majnemer2015-01-091-8/+13
| | | | | | | | | | | Parser::ParseNamespace can get a little confused when it found itself inside a compound statement inside of a non-static data member initializer. Try to determine that the statement expression's scope makes sense before trying to parse it's contents. llvm-svn: 225514
* Parse: Don't crash when trailing return type is missingDavid Majnemer2015-01-091-5/+4
| | | | | | | | | Sema::CheckParmsForFunctionDef can't cope with a null TypeSourceInfo. Don't let the AST contain the malformed lambda. This fixes PR22122. llvm-svn: 225505
* Fix indentation. No behavior change.Nico Weber2015-01-041-1/+1
| | | | llvm-svn: 225129
* Wrap to 80 columns, no behavior change.Nico Weber2015-01-041-4/+5
| | | | llvm-svn: 225122
* Parse: __attribute__((keyword)) shouldn't errorDavid Majnemer2015-01-031-3/+4
| | | | | | | Weird constructs like __attribute__((inline)) or __attibute__((typename)) should result in warnings, not errors. llvm-svn: 225118
* Fix build breakageDavid Majnemer2014-12-291-1/+2
| | | | | | That's what I get for last second changes... llvm-svn: 224967
* Parse: Recover more gracefully from extra :: tokens before a {David Majnemer2014-12-291-1/+11
| | | | | | | Instead of crashing, recover by eating the extra trailing scope qualifier. This means we will treat 'struct A:: {' as 'struct A {'. llvm-svn: 224966
* Crash even less on malformed attributes in an incorrect location.Nico Weber2014-12-291-1/+4
| | | | | | | | | | | This is a follow-up to r224915. This adds a bit more line noise to the tests added in that revision to make sure the parser is ready for a toplevel decl after each incorrect line. Use this to move the tests up to where they belong. This uncovered that the early return was missing a call to ActOnTagDefinitionError(), so add that. (Also fixes at least one of the crashes on SLi's bot.) llvm-svn: 224958
* Parse: Ignore '::' in 'struct :: {'David Majnemer2014-12-291-5/+11
| | | | | | | Let's pretend that we didn't see the '::' instead of go on believing that we've got some anonymous, but globally qualified, struct. llvm-svn: 224945
* Don't crash on malformed attributes in an incorrect location.Nico Weber2014-12-291-0/+10
| | | | | | | | | | | | | | | | | | r168626 added nicer diagnostics for attributes in the wrong places, such as after the `final` on a class. To do this, it added code that did high-level pattern matching for e.g. 'final' 'alignas' '(' and then skipped until the closing ')'. If it saw that, it then went down the regular class parsing path and then called MaybeParseCXX11Attributes() to parse the attribute after the 'final' using real attribute parsing code. On invalid attributes, the real attribute parsing code could eat more tokens than the pattern matching code and for example skip past the '{' starting the class, which would then lead to an assert. To prevent this, check for a good state after calling MaybeParseCXX11Attributes() (which morphed into CheckMisplacedCXX11Attribute() in r175575) and bail out if things look bleak. Found by SLi's afl bot. llvm-svn: 224915
* SemaCXX: Don't crash when annotation tokens show up before the tag nameDavid Majnemer2014-12-291-1/+2
| | | | | | | | Clang has a hack to accept definitions of structs with tag names which have the same name as intrinsics. However, this hack didn't guard against annotation tokens showing up in the token stream. llvm-svn: 224909
* Don't crash on surprising tokens in default parameter template lists.Nico Weber2014-12-282-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Fixes this snippet from SLi's afl fuzzer output: class { i (x = <, enum This parsed i as a function, x as a paramter, and the stuff after < as a template list. This then called TryConsumeDeclarationSpecifier() which called TryAnnotateCXXScopeToken() without checking the preconditions of this function. Check them before calling, like all other callers of TryAnnotateCXXScopeToken() do. A more readable reproducer that causes the same crash is class { void i(int x = MyTemplateClass<int, union int>::foo()); }; The reduced version used an eof token as surprising token, but kw_int works just as well to repro and is easier to insert into a test file. llvm-svn: 224906
* Parse: Don't crash when 'typename' shows up in an attributeDavid Majnemer2014-12-281-1/+2
| | | | | | | | | 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. llvm-svn: 224903
* Remove unneeded include of DeclCXX.h from libParse.Nico Weber2014-12-281-1/+0
| | | | llvm-svn: 224893
* Removing an outdated FIXME; try block attributes are parsed with the rest of ↵Aaron Ballman2014-12-201-1/+0
| | | | | | the statement attributes (as per the standard), and function-try-blocks may not have attributes. NFC. llvm-svn: 224662
* Added a fixit to remove empty parens from a C++11 attribute argument list ↵Aaron Ballman2014-12-191-2/+2
| | | | | | when we diagnose this as an error. llvm-svn: 224595
* Fix layering violation, Lex shouldn't know about DeclDavid Majnemer2014-12-191-2/+2
| | | | llvm-svn: 224562
* PR21969: Improve diagnostics for a conversion function that has any pieces of aRichard Smith2014-12-191-1/+1
| | | | | | declared return type (including a trailing-return-type in C++14). llvm-svn: 224561
* Correct delayed typos in the operand to typeof expressions.Kaelyn Takata2014-12-191-2/+2
| | | | | | Fixes PR21947. llvm-svn: 224558
* Parse: Don't parse after the eof has been consumedDavid Majnemer2014-12-181-1/+4
| | | | | | | | | | | | | | ParseCXXNonStaticMemberInitializer stashes away all the tokens for the initializer and an additional EOF token to denote where the initializer ends. However, it is possible for ParseLexedMemberInitializer to get its hands on the "real" EOF token; since the two tokens are indistinguishable, we end up consuming the EOF and descend into madness. Instead, make it possible to tell which EOF token we are looking at. This fixes PR21872. llvm-svn: 224505
* Rangify for loop, NFC.Yaron Keren2014-12-171-4/+2
| | | | llvm-svn: 224434
* Parse: Consume tokens more carefully in CheckForLParenAfterColonColonDavid Majnemer2014-12-171-27/+29
| | | | | | | | | We would consume the lparen even if it wasn't followed by an identifier or a star-identifier pair. This fixes PR21815. llvm-svn: 224403
* Diagnose function template definitions inside functionsReid Kleckner2014-12-153-4/+16
| | | | | | | | | | | | | | | 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. llvm-svn: 224287
* Parse: MS property members cannot have an in-class initializerDavid Majnemer2014-12-131-1/+4
| | | | | | | | | We would crash trying to treat a property member as a field. These shoudl be forbidden anyway, reject programs which contain them. This fixes PR21840. llvm-svn: 224193
* Fix two small bugs in typo correction. One assertion failure building member ↵Nick Lewycky2014-12-131-0/+2
| | | | | | | | expressions because the lookup finds a different name than the original, fixed by updating the LookupResult's name with the name of the found decl. Second is that we also diagnose delayed typo exprs in the index of an array subscript expression. The testcase shows a third bug with a FIXME in it. llvm-svn: 224183
* Parse: Concatenated string literals should be verified in inline asmDavid Majnemer2014-12-111-16/+13
| | | | | | | | | | While we would correctly handle asm("foo") and reject asm(L"bar"), we weren't careful to handle cases where an ascii literal could be concatenated with a wide literal. This fixes PR21822. llvm-svn: 223992
* Modified the Objective-C lexer and parser (only Sean Callanan2014-12-091-2/+8
| | | | | | | | | | | | | | | | in debugger mode) to accept @import declarations and pass them to the debugger. In the preprocessor, accept import declarations if the debugger is enabled, but don't actually load the module, just pass the import path on to the preprocessor callbacks. In the Objective-C parser, if it sees an import declaration in statement context (usual for LLDB), ignore it and return a NullStmt. llvm-svn: 223855
* Parse qualifiers after comma in declarator lists as a Microsoft extensionNico Rieck2014-12-041-0/+40
| | | | | | MSVC parses and ignores these with a warning. llvm-svn: 223413
* Recognize __unaligned keyword after type specifierNico Rieck2014-12-041-0/+1
| | | | | | | | The __unaligned keyword can appear after a struct definition: struct foo {...} __unaligned *x; llvm-svn: 223412
* Fix PR21684 - Ellipsis following an 'auto' parameter sans name/ID Faisal Vali2014-12-041-7/+8
| | | | | | | | should indicate a c++ parameter pack not a c-variadic. int i = [](auto...) { return 0; }(); // OK now. llvm-svn: 223357
* Handle delayed corrections in a couple more error paths in ↵Kaelyn Takata2014-12-031-0/+2
| | | | | | ParsePostfixExpressionSuffix. llvm-svn: 223209
* Ensure typos in the default values of template parameters get diagnosed.Kaelyn Takata2014-12-021-1/+1
| | | | llvm-svn: 223177
* Diagnose TypoExprs in a couple of error cases in ParsePostfixExpressionSuffix.Kaelyn Takata2014-12-021-2/+6
| | | | | | | Also have CorrectDelayedTyposInExpr check that the Expr* isn't null before trying to access its members. Fixes PR21679. llvm-svn: 223162
* [c++1z] Remove terse range-based for loops; they've been removed fromRichard Smith2014-11-271-3/+1
| | | | | | consideration for C++17 for now. Update C++ status page to match. llvm-svn: 222865
* [OpenCL] Generic address space has been added in OpenCL v2.0.Anastasia Stulova2014-11-261-0/+25
| | | | | | | | | | 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. llvm-svn: 222831
* Fix crash when using __if_exists in C modeNico Rieck2014-11-241-2/+3
| | | | llvm-svn: 222665
* Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata2014-11-216-7/+23
| | | | | | when calling DiagnoseEmptyLookup. llvm-svn: 222551
* PR21565: Further refine the conditions for enabling eager parsing ofRichard Smith2014-11-202-9/+24
| | | | | | | | 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. llvm-svn: 222471
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-208-31/+72
| | | | | | | | | 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<>). llvm-svn: 222464
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-1/+1
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* PR21565 Add an egregious hack to support broken libstdc++ headers that declareRichard Smith2014-11-141-1/+2
| | | | | | | | | | | | 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. llvm-svn: 221955
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-135-11/+161
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* [OPENMP] Codegen for threadprivate variablesAlexey Bataev2014-11-111-2/+1
| | | | | | | | | For all threadprivate variables which have constructor/destructor emit call to void __kmpc_threadprivate_register(ident_t * <Current Location>, void *<Original Global Addr>, kmpc_ctor <Constructor>, kmpc_cctor NULL, kmpc_dtor <Destructor>); In expressions all references to such variables are replaced by calls to void *__kmpc_threadprivate_cached(ident_t *<Current Location>, kmp_int32 <Current Thread Id>, void *<Original Global Addr>, size_t <Size of Data>, void ***<Pointer to autogenerated cache – array of private copies of threadprivate variable>); Test test/OpenMP/threadprivate_codegen.cpp checks that codegen is correct. Also it checks that codegen is correct after serialization/deserialization and one of passes verifies debug info. Differential Revision: http://reviews.llvm.org/D4002 llvm-svn: 221663
* Fix parsing of fold-expressions within a cast expression. We parse theRichard Smith2014-11-111-5/+11
| | | | | | | parenthesized expression a bit differently in this case, just in case the commas have special meaning. llvm-svn: 221661
* Improve diagnostics if _Noreturn is placed after a function declarator. ↵Richard Smith2014-11-101-1/+22
| | | | | | (This sometimes happens when a macro is used that expands to either the GNU noreturn attribute or _Noreturn.) llvm-svn: 221630
* Updated the wording for a diagnostic to be more grammatically correct, and ↵Aaron Ballman2014-11-082-2/+7
| | | | | | use a %select. Also ensure that nested namespace definitions are diagnosed properly. Both changes are motivated by post-commit feedback from r221580. llvm-svn: 221581
* [c++1z] Support for attributes on namespaces and enumerators.Aaron Ballman2014-11-082-9/+20
| | | | llvm-svn: 221580
* [c++1z] Support for u8 character literals.Richard Smith2014-11-082-0/+2
| | | | llvm-svn: 221576
* [c++1z] Implement nested-namespace-definitions.Richard Smith2014-11-081-19/+18
| | | | | | | | | | | | | This allows 'namespace A::B { ... }' as a shorthand for 'namespace A { namespace B { ... } }'. We already supported this correctly for error recovery; promote that support to a full implementation. This is not the right implementation: we do not maintain source fidelity because we desugar the nested namespace definition in the parser. This is tricky to avoid, since the definition genuinely does inject one named entity per level in the namespace name. llvm-svn: 221574
OpenPOWER on IntegriCloud