summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add code completion to produce "else" blocks after an "if"Douglas Gregor2011-07-301-0/+3
| | | | | | statement. Fixes <rdar://problem/9229438>. llvm-svn: 136564
* Clean up the analysis of the collection operand to ObjCJohn McCall2011-07-271-3/+10
| | | | | | | | | | | for-in statements; specifically, make sure to close over any temporaries or cleanups it might require. In ARC, this has implications for the lifetime of the collection, so emit it with a retain and release it upon exit from the loop. rdar://problem/9817306 llvm-svn: 136204
* Rename getInstantiationLineNumber to getExpansionLineNumber in bothChandler Carruth2011-07-251-2/+2
| | | | | | SourceManager and FullSourceLoc. llvm-svn: 135969
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-5/+5
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Move the rest of the preprocessor terminology from 'instantiate' andChandler Carruth2011-07-141-1/+1
| | | | | | | | | | | | | variants to 'expand'. This changed a couple of public APIs, including one public type "MacroInstantiation" which is now "MacroExpansion". The rest of the codebase was updated to reflect this, especially the libclang code. Two of the C++ (and thus easily changed) libclang APIs were updated as well because they pertained directly to the old MacroInstantiation class. No functionality changed. llvm-svn: 135139
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-061-3/+9
| | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. llvm-svn: 134548
* Remove the Fix-it for missing statement in switchesDavid Majnemer2011-06-141-6/+4
| | | | llvm-svn: 132994
* Improve the diagnostics generated for switch statements missing expressionsDavid Majnemer2011-06-131-4/+7
| | | | | | | - Move the diagnostic to the case statement instead of at the end of the switch - Add a fix-it hint as to how to fix the compilation error llvm-svn: 132903
* Add support for _if_exists and __if_not_exists at namespace/global scope.Francois Pichet2011-05-071-37/+4
| | | | llvm-svn: 131050
* Add support for Microsoft __if_exists and __if_not_exists construct inside ↵Francois Pichet2011-05-061-0/+70
| | | | | | | | | | | | function definition. Allow to include or exclude code depending on if a symbol exists or not. Just like a #ifdef but for C/C++ symbols. More doc: http://msdn.microsoft.com/en-us/library/x7wy9xh3(v=VS.100).aspx Support at class and namespace scopes will be added later. llvm-svn: 131014
* SEH was crashing under -fms-extensions.Francois Pichet2011-04-281-6/+11
| | | | llvm-svn: 130377
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-15/+144
| | | | | | | | Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
* Introduce a new parser annotation token for primary expressions. WhenDouglas Gregor2011-04-271-7/+8
| | | | | | | ClassifyName() builds a primary expression, generate one of these annotation tokens rather than jumping into the parser. llvm-svn: 130297
* Clean out some cruft I introduced when adding Sema::ClassifyName()Douglas Gregor2011-04-271-4/+0
| | | | llvm-svn: 130295
* Simplify the parser's handling of Sema::ClassifyName() for types, byDouglas Gregor2011-04-271-52/+1
| | | | | | | creating a type-annotation token rather than jumping into the declaration parsing. llvm-svn: 130293
* If a null statement was preceded by an empty macro keep its instantiation ↵Argyrios Kyrtzidis2011-04-271-2/+4
| | | | | | | | source location in NullStmt. llvm-svn: 130289
* Extend Sema::ClassifyName() to support C++, ironing out a few issuesDouglas Gregor2011-04-271-5/+24
| | | | | | | | | in the classification of template names and using declarations. We now properly typo-correct the leading identifiers in statements to types, templates, values, etc. As an added bonus, this reduces the number of lookups required for disambiguation. llvm-svn: 130288
* When Sema::ClassifyName() finds an invalid ivar reference, return anDouglas Gregor2011-04-251-1/+0
| | | | | | | invalid expression rather than the far-more-generic "error". Fixes a mild regression in error recovery uncovered by the GCC testsuite. llvm-svn: 130128
* Implement a new identifier-classification scheme where SemaDouglas Gregor2011-04-241-34/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | performs name lookup for an identifier and resolves it to a type/expression/template/etc. in the same step. This scheme is intended to improve both performance (by reducing the number of redundant name lookups for a given identifier token) and error recovery (by giving Sema a chance to correct type names before the parser has decided that the identifier isn't a type name). For example, this allows us to properly typo-correct type names at the beginning of a statement: t.c:6:3: error: use of undeclared identifier 'integer'; did you mean 'Integer'? integer *i = 0; ^~~~~~~ Integer t.c:1:13: note: 'Integer' declared here typedef int Integer; ^ Previously, we wouldn't give a Fix-It because the typo correction occurred after the parser had checked whether "integer" was a type name (via Sema::getTypeName(), which isn't allowed to typo-correct) and therefore decided to parse "integer * i = 0" as an expression. By typo-correcting earlier, we typo-correct to the type name Integer and parse this as a declaration. Moreover, in this context, we can also typo-correct identifiers to keywords, e.g., t.c:7:3: error: use of undeclared identifier 'vid'; did you mean 'void'? vid *p = i; ^~~ void and recover appropriately. Note that this is very much a work-in-progress. The new Sema::ClassifyName is only used for expression-or-declaration disambiguation in C at the statement level. The next steps will be to make this work for the same disambiguation in C++ (where functional-style casts make some trouble), then push it further into the parser to eliminate more redundant name lookups. Fixes <rdar://problem/7963833> for C and starts us down the path of <rdar://problem/8172000>. llvm-svn: 130082
* Fix gcc warning. Add parens to this assert, incidentally reassociating it, ↵Richard Smith2011-04-211-1/+1
| | | | | | but the condition is the same either way. llvm-svn: 129948
* Add a fixit suggest for missing case keywords inside a switch scope. For ↵Richard Trieu2011-04-211-5/+23
| | | | | | | | | | | instance, in the following code, 'case ' will be suggested before the '1:' switch (x) { 1: return 0; default: return 1; } llvm-svn: 129943
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-12/+42
| | | | | | draft standard (N3291). llvm-svn: 129541
* Insomniac refactoring: change how the parser allocates attributes so thatJohn McCall2011-03-241-8/+8
| | | | | | | | | AttributeLists do not accumulate over the lifetime of parsing, but are instead reused. Also make the arguments array not require a separate allocation, and make availability attributes store their stuff in augmented memory, too. llvm-svn: 128209
* 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
OpenPOWER on IntegriCloud