summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make sure that we always pop a function's scope *before* we callDouglas Gregor2011-03-161-7/+15
| | | | | | | | | | | ActOnFinishFunctionBody/ActOnBlockStmtExpr. This way, we ensure that we diagnose undefined labels before the jump-scope checker gets run, since the jump-scope checker requires (as its invariant) that all of the GotoStmts be wired up correctly. Fixes PR9495. llvm-svn: 127738
* Implement a hack intended to allow Clang to parse libstdc++ 4.5'sDouglas Gregor2011-03-111-1/+10
| | | | | | | | | | | headers, which use C++0x generalized initializer lists. Per PR7069, it appears that the only use is as the return type of a function, so this commit enables this extension just in that narrow case. If it's enough for libstdc++ 4.5, or if it can be trivially extended to work with libstdc++ 4.5, we'll keep it. Otherwise, or if this breaks anything, we'll revert and wait for the real feature. llvm-svn: 127507
* Fixed LabelDecl source range and cleaned creation code.Abramo Bagnara2011-03-051-1/+1
| | | | llvm-svn: 127094
* implement basic support for __label__. I wouldn't be shocked if there areChris Lattner2011-02-181-4/+33
| | | | | | | | | bugs from other clients that don't expect to see a LabelDecl in a DeclStmt, but if so they should be easy to fix. This implements most of PR3429 and rdar://8287027 llvm-svn: 125817
* Switch labels over to using normal name lookup, instead of their Chris Lattner2011-02-181-6/+11
| | | | | | | own weird little DenseMap. Hey look, we now emit unused label warnings deterministically, amazing. llvm-svn: 125813
* Improve parser recovery in "for" statements, from Richard Smith!Douglas Gregor2011-02-171-7/+18
| | | | llvm-svn: 125722
* Improve our parse recovery on 'case blah;' and 'default;'.John McCall2011-01-221-6/+18
| | | | llvm-svn: 124025
* Fix warnings found by gcc-4.6, from -Wunused-but-set-variable andJeffrey Yasskin2011-01-181-4/+1
| | | | | | -Wint-to-pointer-cast. llvm-svn: 123719
* Convert "#pragma unused(...)" into tokens for the parser.Argyrios Kyrtzidis2011-01-171-0/+6
| | | | | | | This allows us to cache a "#pragma unused" that occurs inside an inline C++ member function. Fixes rdar://8829590&8770988. llvm-svn: 123666
* Rename MaybeSkipFunctionBodyForCodeCompletion -> ↵Argyrios Kyrtzidis2011-01-041-8/+9
| | | | | | | | trySkippingFunctionBodyForCodeCompletion and check isCodeCompletionEnabled() before doing the call. Suggestions by Chris. llvm-svn: 122792
* When in code-completion, skip obj-c method bodies for speed up.Argyrios Kyrtzidis2011-01-031-12/+25
| | | | llvm-svn: 122781
* Speed up code-completion by skipping function bodies.Argyrios Kyrtzidis2011-01-031-0/+13
| | | | | | | | | | | | | | When we are in code-completion mode, skip parsing of all function bodies except the one where the code-completion point resides. For big .cpp files like 'SemaExpr.cpp' the improvement makes a huge difference, in some cases cutting down code-completion time -62% ! We don't get diagnostics for the bodies though, so modify the code-completion tests that check for errors. See rdar://8814203. llvm-svn: 122765
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-54/+47
| | | | | | | on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. llvm-svn: 122535
* Improve the diagnostic and recovery for missing colons after 'case'Douglas Gregor2010-12-231-12/+16
| | | | | | | | | | | | | | | and 'default' statements, including a Fix-It to add the colon: test/Parser/switch-recovery.cpp:13:12: error: expected ':' after 'case' case 17 // expected-error{{expected ':' after 'case'}} ^ : test/Parser/switch-recovery.cpp:16:12: error: expected ':' after 'default' default // expected-error{{expected ':' after 'default'}} ^ : llvm-svn: 122522
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-3/+9
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Fixed source range for MS asm statement.Abramo Bagnara2010-12-021-4/+7
| | | | llvm-svn: 120724
* Revert r119838 "Don't warn for empty 'if' body if there is a macro that ↵Argyrios Kyrtzidis2010-11-201-15/+7
| | | | | | | | | | expands to nothing" and use a better and more general approach, where NullStmt has a flag to indicate whether it was preceded by an empty macro. Thanks to Abramo Bagnara for the hint! llvm-svn: 119887
* Don't warn for empty 'if' body if there is a macro that expands to nothing, e.g:Argyrios Kyrtzidis2010-11-191-3/+13
| | | | | | | | | if (condition) CALL(0); // empty macro but don't warn for empty body. Fixes rdar://8436021. llvm-svn: 119838
* Region-allocate all AttributeList objects from a factory object instead of ↵Ted Kremenek2010-11-101-34/+19
| | | | | | | | | | | | | | | | | | | | | | | | manually managing them using new/delete and OwningPtrs. After memory profiling Clang, I witnessed periodic leaks of these objects; digging deeper into the code, it was clear that our management of these objects was a mess. The ownership rules were murky at best, and not always followed. Worse, there are plenty of error paths where we could screw up. This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList objects and then blows them away all at once. While conceptually simple, most of the changes in this patch just have to do with migrating over to the new interface. Most of the changes have resulted in some nice simplifications. This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser object. This is easily tunable. If we desire to have more bound the lifetime of AttributeList objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its underlying allocator as we enter/leave key methods in the Parser. This means that we get simple memory management while still having the ability to finely control memory use if necessary. Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic in many large files with attributes. This fixes the leak reported in: <rdar://problem/8650003> llvm-svn: 118675
* Properly handle temporaries that are created in a AsmStmt.Argyrios Kyrtzidis2010-11-021-1/+1
| | | | | | Previously the temporaries would get destroyed before the asm call. llvm-svn: 118001
* Clean up temporaries created by an asm statement. Fixes rdar://8540491Argyrios Kyrtzidis2010-11-011-0/+1
| | | | llvm-svn: 117961
* vla expressions used in __typeof__ must be evaluated.Fariborz Jahanian2010-09-281-9/+10
| | | | | | Fixes rdar://8476159. llvm-svn: 114982
* Don't warn for an unused label if it has 'unused' attribute. Fixes ↵Argyrios Kyrtzidis2010-09-281-2/+1
| | | | | | rdar://8483139. llvm-svn: 114954
* Implement bracket insertion for Objective-C instance message sends asDouglas Gregor2010-09-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
* Improve recovery when there is a stray ']' or ')' before the ';' atDouglas Gregor2010-09-071-2/+2
| | | | | | the end of a statement. Fixes <rdar://problem/6896493>. llvm-svn: 113202
* when emitting an error about a missing } in a compound statement, emitChris Lattner2010-09-011-0/+1
| | | | | | a "to match this {" note, pointing out the opener. llvm-svn: 112709
* Revert my user-defined literal commits - r1124{58,60,67} pendingAlexis Hunt2010-08-301-2/+1
| | | | | | some issues being sorted out. llvm-svn: 112493
* Implement C++0x user-defined string literals.Alexis Hunt2010-08-291-1/+2
| | | | | | | | | | The extra data stored on user-defined literal Tokens is stored in extra allocated memory, which is managed by the PreprocessorLexer because there isn't a better place to put it that makes sure it gets deallocated, but only after it's used up. My testing has shown no significant slowdown as a result, but independent testing would be appreciated. llvm-svn: 112458
* One who seeks knowledge learns something new every day.John McCall2010-08-261-9/+8
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-61/+61
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-37/+37
| | | | llvm-svn: 111863
* Introduce a code-completion hook for the Objective-C collectionDouglas Gregor2010-08-231-0/+10
| | | | | | | | argument in a for-each statement (e.g., "for (id x in <blah>)"), which restricts the expression completions provided to Objective-C types (or class types in C++). llvm-svn: 111843
* Sundry incremental steps towards killing off Action.John McCall2010-08-231-16/+16
| | | | llvm-svn: 111795
* DeclPtrTy -> Decl *John McCall2010-08-211-13/+13
| | | | llvm-svn: 111733
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-2/+2
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Add a slightly better hack for microsoft style inline asm, Chris Lattner2010-08-171-2/+2
| | | | | | patch by Per Linden! llvm-svn: 111235
* Once code completion has completed, pass a "completion context" on toDouglas Gregor2010-08-111-3/+3
| | | | | | | the code-completion consumer. The consumer can use this information to augument, filter, or display the code-completion results. llvm-svn: 110858
* Remove ElseScope which is also dead code now.Nick Lewycky2010-08-061-6/+0
| | | | llvm-svn: 110433
* Fix PR7673 by allowing an empty clobbers section in an ASM statement.Chandler Carruth2010-07-221-8/+10
| | | | llvm-svn: 109087
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-13/+13
| | | | | | | | | | | | | | allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
* Make sure parens/braces/brackets are correctly balanced.Argyrios Kyrtzidis2010-06-171-0/+2
| | | | | | | | | | | In a line like: (; the semicolon leaves Parser:ParenCount unbalanced (it's 1 even though we stopped looking for a right paren). This may affect later parsing and result in bad recovery for parsing errors. llvm-svn: 106213
* Teach code completion to adjust its completion priorities based on theDouglas Gregor2010-05-301-0/+7
| | | | | | | | | type that we expect to see at a given point in the grammar, e.g., when initializing a variable, returning a result, or calling a function. We don't prune the candidate set at all, just adjust priorities to favor things that should type-check, using an ultra-simplified type system. llvm-svn: 105128
* Make -code-completion-patterns only cover multi-line codeDouglas Gregor2010-05-281-1/+1
| | | | | | | completions. Plus, tweak a few completion patterns to better reflect the language grammar. llvm-svn: 104905
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-251-2/+2
| | | | | | | | | | | 1) Suppress diagnostics as soon as we form the code-completion token, so we don't get any error/warning spew from the early end-of-file. 2) If we consume a code-completion token when we weren't expecting one, go into a code-completion recovery path that produces the best results it can based on the context that the parser is in. llvm-svn: 104585
* Improve parser recovery when a switch condition is invalid; fixesDouglas Gregor2010-05-201-3/+4
| | | | | | <rdar://problem/7971948>. llvm-svn: 104291
* Fixed DISABLE_SMART_POINTERS breakageDouglas Gregor2010-05-061-1/+3
| | | | llvm-svn: 103198
* Rework our handling of temporary objects within the conditions ofDouglas Gregor2010-05-061-32/+55
| | | | | | | | | | | | | | | | | | | if/switch/while/do/for statements. Previously, we would end up either: (1) Forgetting to destroy temporaries created in the condition (!), (2) Destroying the temporaries created in the condition *before* converting the condition to a boolean value (or, in the case of a switch statement, to an integral or enumeral value), or (3) In a for statement, destroying the condition's temporaries at the end of the increment expression (!). We now destroy temporaries in conditions at the right times. This required some tweaking of the Parse/Sema interaction, since the parser was building full expressions too early in many places. Fixes PR7067. llvm-svn: 103187
* change Scope::WithinElse to be a normal scope flag, widen theChris Lattner2010-04-121-5/+8
| | | | | | fields to two 16-bit values instead of using bitfields. llvm-svn: 101020
* fix PR6782, an accept invalid. We weren't emitting the diagnostic Chris Lattner2010-04-051-1/+1
| | | | | | returned by SetTypeSpecType. llvm-svn: 100443
* Don't skip past the '}' if an expression has error and is not followed by ';'.Argyrios Kyrtzidis2010-03-311-3/+5
| | | | llvm-svn: 99972
OpenPOWER on IntegriCloud