summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
...
* Sema: Properly track mangling number/name for linkage for using declsDavid Majnemer2015-03-111-5/+8
| | | | | | | | | | | | Using declarations which are aliases to struct types have their name used as the struct type's name for linkage purposes. Otherwise, make sure to give an anonymous struct defined inside a using declaration a mangling number to disambiguate it from other anonymous structs in the same context. This fixes PR22809. llvm-svn: 231909
* Fix a theoretical bug when ParseCompoundStatement() returns StmtError.Nico Weber2015-03-091-1/+3
| | | | | | | | ParseCompoundStatement() currently never returns StmtError, but if it did, Sema would keep the __finally scope on its stack indefinitely. Explicitly add an error callback that clears it. llvm-svn: 231625
* Warn when jumping out of a __finally block via continue, break, return, __leave.Nico Weber2015-03-091-2/+5
| | | | | | | | | | | | | | | Since continue, break, return are much more common than __finally, this tries to keep the work for continue, break, return O(1). Sema keeps a stack of active __finally scopes (to do this, ActOnSEHFinally() is split into ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump statements then check if the current __finally scope (if present) is deeper than then destination scope of the jump. The same warning for goto statements is still missing. This is the moral equivalent of MSVC's C4532. llvm-svn: 231623
* Simplify boolean expressions in clang with clang-tidyDavid Blaikie2015-03-091-1/+1
| | | | | | | | Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8155 llvm-svn: 231619
* Make Token a real POD type.Benjamin Kramer2015-03-081-0/+1
| | | | | | | We copy them around a lot and skip construction in favor of startToken, make the default construction trivial to reflect that. llvm-svn: 231603
* Wrap to 80 columns. No behavior change.Nico Weber2015-03-071-2/+4
| | | | llvm-svn: 231573
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-252-10/+6
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* Don't crash on missing '{' after __except or __finally, PR22687.Nico Weber2015-02-251-2/+8
| | | | | | Also add some general test/Parser coverage for SEH blocks. llvm-svn: 230449
* Fold ParseSEHTryBlockCommon() into its only caller. No behavior change.Nico Weber2015-02-251-7/+4
| | | | | | | ParseCXXTryBlockCommon() makes sense because it has two callers due to function try blocks. There are no SEH function try blocks. llvm-svn: 230426
* Revert "Improve declaration / expression disambiguation around ↵Justin Bogner2015-02-231-44/+22
| | | | | | | | | | | ptr-operators, and use" This seems to break mixing function-style and c-style casts, and is breaking bootstrapping llvm. This reverts r230261. llvm-svn: 230274
* Improve declaration / expression disambiguation around ptr-operators, and useRichard Smith2015-02-231-22/+44
| | | | | | | | the presence of an abstract declarator with a ptr-operator as proof that a construct cannot parse as an expression to improve diagnostics along error recovery paths. llvm-svn: 230261
* FIX PR 18432, default args, friends & late-parsed members.Nathan Sidwell2015-02-192-4/+18
| | | | | | | | | | | | Sema::MergeCXXFunctionDecl: propagate hasUnparsedDefaultArg to new decl. Parser::HandleMemberFunctionDeclDelays: check hasUnparsedDefaultArg flag. Parser::ParseLexedMethodDeclaration: handle inherited unparsed default arg case. llvm-svn: 229852
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-181-9/+11
| | | | llvm-svn: 229637
* For variables with dependent type, don't crash on `var->::new` or `var->__super`Nico Weber2015-02-161-6/+8
| | | | | | | | | | | | | | | | | | | | | ParsePostfixExpressionSuffix() for '->' (or '.') postfixes first calls ActOnStartCXXMemberReference() to inform sema that a member reference is about to start, and that function lets the parser know if sema thinks that the base expression's type could allow a pseudo destructor from a semantic point of view (for example, if the the base expression has a dependent type). ParsePostfixExpressionSuffix() then calls ParseOptionalCXXScopeSpecifier() and passes MayBePseudoDestructor on to that function, expecting the function to set it to false if a pseudo destructor is impossible from a syntactic point of view (due to a lack of '~' sigil). However, ParseOptionalCXXScopeSpecifier() had early-outs for ::new and __super, so MayBePseudoDestructor stayed true, so we tried to parse a pseudo dtor, and then became confused since we couldn't find a '~'. Move the snippet in ParseOptionalCXXScopeSpecifier() that sets MayBePseudoDestructor to false above the early exits. Parts of this found by SLi's bot. llvm-svn: 229449
* Parse: return true from ParseCXX11AttributeArgs if an attribute was addedSaleem Abdulrasool2015-02-161-2/+0
| | | | | | | | | | | | | | | | | | In the case that we diagnosed an invalid attribute due to missing or present arguments, we would return false, indicating to the caller that the parsing failed. However, we would have added the attribute in ParseAttributeArgsCommon (which may have been called indirectly through ParseGNUAttributeArgs). Returning true in this case ensures that a second copy of the attribute is not added. I haven't added a test case for this as the existing test will cover this with the next commit which diagnoses a C++14 attribute applied in C++11 mode. Rather than duplicating the existing test case, allow the tree to remain without a test between this and the next change. We would see double warnings in the [[deprecated()]] applied to a declaration in C++11 mode, which will cause an error in the cxx0x-attributes test. llvm-svn: 229446
* Fix typo in comment.Nico Weber2015-02-161-2/+2
| | | | llvm-svn: 229432
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-4/+4
| | | | | | requiring the macro. NFC; Clang edition. llvm-svn: 229339
* Don't crash on `struct ::, struct ::` (and the same for enums).Nico Weber2015-02-152-5/+16
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 229288
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-151-1/+2
| | | | llvm-svn: 229282
* Add a warning for direct-list-initialization of a variable with a deduced typeRichard Smith2015-02-111-3/+8
| | | | | | | | (or of a lambda init-capture, which is sort-of such a variable). The semantics of such constructs will change when we implement N3922, so we intend to warn on this in Clang 3.6 then change the semantics in Clang 3.7. llvm-svn: 228792
* Parse: Handle __declspec in a lambda definitionDavid Majnemer2015-02-041-0/+5
| | | | llvm-svn: 228121
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-021-1/+2
| | | | llvm-svn: 227782
* Follow-up to r217302: Don't crash on ~A::A in a postfix expr suffix followed ↵Nico Weber2015-02-021-0/+2
| | | | | | | | | | | | | | | | | by '<'. This used to crash, complaining "ObjectType and scope specifier cannot coexist": struct A { } b = b.~A::A <int>; The only other caller of ParseOptionalCXXScopeSpecifier() that passes in a non-empty ObjectType clears the ObjectType of the scope specifier comes back non-empty (see the tok::period case in Parser::ParsePostfixExpressionSuffix()), so do that here too. Found by SLi's bot. llvm-svn: 227781
* Remove a comment I accidentally added in r227581. No behavior change.Nico Weber2015-02-021-2/+1
| | | | llvm-svn: 227777
* Follow-up to r217302 and r227555: Don't crash on inline ~A::A() if A is an int.Nico Weber2015-01-301-1/+7
| | | | | | | | | | | | | | | | | | | Even with r227555, this still crashed: struct S { int A; ~A::A() {} }; That's because ParseOptionalCXXScopeSpecifier()'s call to ActOnCXXNestedNameSpecifier() doesn't mark the scope spec as invalid if sema thought it's a good idea to fixit-correct "::" to ":". For the diagnostic improvement done in r217302, we never want :: to be interpreted as :, so fix this by setting ColonSacred to false temporarily. Found by SLi's bot. llvm-svn: 227581
* Code cleanupNathan Sidwell2015-01-301-10/+8
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Follow-up to r217302: Don't crash on ~A::A() if A is undeclared.Nico Weber2015-01-301-1/+2
| | | | llvm-svn: 227555
* Enable pragma comment processing for PS4. Original patch by Yunzhong Gao!Alex Rosenberg2015-01-281-0/+6
| | | | llvm-svn: 227336
* Remove duplicate codeNathan Sidwell2015-01-251-32/+18
| | | | llvm-svn: 227024
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering looks a lot like normal EH lowering, with the exception that the exceptions are caught by executing filter expression code instead of matching typeinfo globals. The filter expressions are outlined into functions which are used in landingpad clauses where typeinfo would normally go. Major aspects that still need work: - Non-call exceptions in __try bodies won't work yet. The plan is to outline the __try block in the frontend to keep things simple. - Filter expressions cannot use local variables until capturing is implemented. - __finally blocks will not run after exceptions. Fixing this requires work in the LLVM SEH preparation pass. The IR lowering looks like this: // C code: bool safe_div(int n, int d, int *r) { __try { *r = normal_div(n, d); } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) { return false; } return true; } ; LLVM IR: define i32 @filter(i8* %e, i8* %fp) { %ehptrs = bitcast i8* %e to i32** %ehrec = load i32** %ehptrs %code = load i32* %ehrec %matches = icmp eq i32 %code, i32 u0xC0000094 %matches.i32 = zext i1 %matches to i32 ret i32 %matches.i32 } define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) { %rr = invoke i32 @normal_div(i32 %n, i32 %d) to label %normal unwind to label %lpad normal: store i32 %rr, i32* %r ret i1 1 lpad: %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*) %ehptr = extractvalue {i8*, i32} %ehvals, i32 0 %sel = extractvalue {i8*, i32} %ehvals, i32 1 %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*)) %matches = icmp eq i32 %sel, %filter_sel br i1 %matches, label %eh.except, label %eh.resume eh.except: ret i1 false eh.resume: resume } Reviewers: rjmccall, rsmith, majnemer Differential Revision: http://reviews.llvm.org/D5607 llvm-svn: 226760
* Initial support for C++ parameter completionFrancisco Lopes da Silva2015-01-213-11/+24
| | | | | | | | | | | | | | | | | | | | 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? llvm-svn: 226670
* Address review feedback from r226306. No intended behavior change.Nico Weber2015-01-171-2/+2
| | | | llvm-svn: 226363
* Adding option -fno-inline-asm to disallow inline asmSteven Wu2015-01-161-0/+5
| | | | | | | | | | | | | | | | Summary: This patch add a new option to dis-allow all inline asm. Any GCC style inline asm will be reported as an error. Reviewers: rnk, echristo Reviewed By: rnk, echristo Subscribers: bob.wilson, rnk, echristo, rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D6870 llvm-svn: 226340
* Fix a case where delayed typo correction should have resolved anKaelyn Takata2015-01-161-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ambiguity but wasn't. In the new test case, "click" wasn't being corrected properly because Sema::ClassifyName would call CorrectTypo for "click" then later Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use of "click" (the former by the parser needing to determine what the identifier is so it knows how to parse the statement, i.e. is it the beginning of a declaration or an expression). CorrectTypo would record that typo correction for "click" failed and CorrectTypoDelayed would see that and not even try to correct the typo, even though in this case CorrectTypo failed due to an ambiguity (both "Click" and "clock" having an edit distance of one from "click") that could be resolved with more information. The fix is two-fold: 1) Have CorrectTypo not record failed corrections if the reason for the failure was two or more corrections with the same edit distance, and 2) Make the CorrectionCandidateCallback used by Parser::ParseCastExpression reject FunctionDecl candidates when the next token after the identifier is a ".", "=", or "->" since functions cannot be assigned to and do not have members that can be referenced. The reason for two correction spots is that from r222549 until r224375 landed, the first correction attempt would fail completely but the second would suggest "clock" while having the note point to the declaration of "Click". llvm-svn: 226334
* Spell 0 in an enum-appropriate way. No behavior change.Nico Weber2015-01-161-1/+1
| | | | llvm-svn: 226307
* Don't crash if a declarator in a friend decl doesn't have a name.Nico Weber2015-01-161-12/+16
| | | | | | | | | | | There was already an explicit check for that for the first decl. Move that to a different place so that it's called for the following decls too. Also don't randomly set the BitfieldSize ExprResult to true (this sets a pointer to true internally). Found by SLi's bot. llvm-svn: 226306
* Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.Richard Smith2015-01-152-1/+15
| | | | llvm-svn: 226067
* [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+1
| | | | | | | | | | Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. llvm-svn: 225979
* Parse: Switch to using EOF tokens for late parsed attributesDavid Majnemer2015-01-131-12/+15
| | | | | | | | | 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. llvm-svn: 225776
* Parse: Don't crash if missing an initializer expressionDavid Majnemer2015-01-131-1/+2
| | | | llvm-svn: 225768
* Parse: use the EOF token method to lex inline method bodiesDavid Majnemer2015-01-131-20/+23
| | | | | | | | Mark the end of the method body with an EOF token, collect it once we expect to be done with method body parsing. No functionality change intended. llvm-svn: 225765
* Parse: Further simplify ParseLexedMethodDeclarationDavid Majnemer2015-01-133-46/+33
| | | | | | | No functionality change intended, just moving code around to make it simpler. llvm-svn: 225763
* If we don't find a matching ) for a ( in an exception specification, keep ↵Richard Smith2015-01-131-9/+4
| | | | | | the tokens around so we can diagnose an error rather than silently discarding them. llvm-svn: 225755
* [PowerPC]To provide better compatibility with gcc I added the __bool keyword ↵Bill Seurer2015-01-122-0/+6
| | | | | | | | | | | | | | | | | 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 llvm-svn: 225664
* Parse: Get rid of cxx_exceptspec_end, use EOF insteadDavid Majnemer2015-01-122-3/+7
| | | | | | | | Similar to r225619, use a special EOF token to mark the end of the exception specification instead of cxx_exceptspec_end. Use the current scope as the marker. llvm-svn: 225622
* Parse: Just a small tidy-up in ParseLexedMethodDeclarationDavid Majnemer2015-01-121-5/+7
| | | | | | No functional change intended, just tidy up the parse flow. llvm-svn: 225620
* Parse: Get rid of tok::cxx_defaultarg_end, use EOF insteadDavid Majnemer2015-01-123-8/+9
| | | | | | | 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. llvm-svn: 225619
* Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directlyDavid Majnemer2015-01-123-11/+9
| | | | llvm-svn: 225616
* Parse: Don't let BalancedDelimiterTracker consume cxx_defaultarg_endDavid Majnemer2015-01-121-1/+1
| | | | | | | | It is not correct to let it consume the cxx_defaultarg_end token. I'm starting to wonder if it makes more sense to stop SkipUntil from consuming such tokens. llvm-svn: 225615
* Parse: Don't parse beyond the end of the synthetic default argument tokDavid Majnemer2015-01-121-3/+10
| | | | | | | | Recovery from malformed lambda introducers would find us consuming the synthetic default argument token, which is bad. Instead, stop right before that token. llvm-svn: 225613
OpenPOWER on IntegriCloud