summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-19/+19
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-4/+2
| | | | | | | | | | grammar requires a string-literal and not a user-defined-string-literal. The two constructs are still represented by the same TokenKind, in order to prevent a combinatorial explosion of different kinds of token. A flag on Token tracks whether a ud-suffix is present, in order to prevent clients from needing to look at the token's spelling. llvm-svn: 152098
* Handle "#pragma GCC visibility" in a few more places. Switch over "#pragma ↵Eli Friedman2012-02-231-0/+8
| | | | | | | | pack" to use the same handling that gcc does. Fixes <rdar://problem/10871094> and <rdar://problem/10893316>. (Hopefully, common usage of these pragmas isn't irregular enough to break our current handling. Doug has ideas for a more crazy approach if necessary.) llvm-svn: 151307
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-3/+0
| | | | | | direct member initializers. llvm-svn: 151155
* Don't assume that a valid expression for the first part of a for-statementRichard Smith2012-02-211-2/+1
| | | | | | is non-null when diagnosing a broken attempt to write a for-range-statement. llvm-svn: 151081
* Reject continue/break statements within members of local functions nested withinRichard Smith2012-02-171-7/+14
| | | | | | | | | | | | | | | loop and switch statements, by teaching Scope that a function scope never has a continue/break parent for the purposes of control flow. Remove the hack in block and lambda expressions which worked around this by pretending that such expressions were continue/break scopes. Remove Scope::ControlParent, since it's unused. In passing, teach default statements to recover properly from a missing ';', and add a fixit for same to both default and case labels (the latter already recovered correctly). llvm-svn: 150776
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-141-5/+15
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-1/+1
| | | | llvm-svn: 149127
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-3/+0
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Add -Wdangling-else.Nico Weber2011-12-221-13/+25
| | | | | | | This works like described in http://drdobbs.com/blogs/cpp/231602010 Fixes http://llvm.org/PR11609 llvm-svn: 147202
* PR11297: Provide a better diagnostic for code which contains aRichard Smith2011-12-201-0/+8
| | | | | | | | reasonable-looking but ill-formed for-range statement of the form: for (expression : expression) llvm-svn: 147006
* Fix tentative parsing so it knows how to handle an ambiguous ↵Eli Friedman2011-12-201-1/+1
| | | | | | for-range-declaration. PR11601. llvm-svn: 146953
* Fix test regression introduced by r145656. When seeing a string literal ↵Ted Kremenek2011-12-021-1/+6
| | | | | | that isn't accepted by 'asm', skip to the enclosing ')'. llvm-svn: 145662
* Implement support for dependent Microsoft __if_exists/__if_not_existsDouglas Gregor2011-10-251-1/+10
| | | | | | | | | | statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
* Rework Microsoft __if_exists/__if_not_exists parsing and semanticDouglas Gregor2011-10-241-12/+31
| | | | | | | | | | | | | | | | | analysis to separate dependent names from non-dependent names. For dependent names, we'll behave differently from Visual C++: - For __if_exists/__if_not_exists at class scope, we'll just warn and then ignore them. - For __if_exists/__if_not_exists in statements, we'll treat the inner statement as a compound statement, which we only instantiate in templates where the dependent name (after instantiation) exists. This behavior is different from VC++, but it's as close as we can get without encroaching ridiculousness. The latter part (dependent statements) is not yet implemented. llvm-svn: 142864
* Treat the Microsoft/Borland keyword "__except" as a context-sensitiveDouglas Gregor2011-10-211-3/+7
| | | | | | | keyword, because both libstdc++ and libc++ use "__except" as an identifier. Fixes <rdar://problem/10322555>. llvm-svn: 142636
* Implement -Wc++98-compat warnings for the parser.Richard Smith2011-10-151-4/+6
| | | | llvm-svn: 142056
* Introduce BalancedDelimiterTracker, to better track open/closeDouglas Gregor2011-10-121-34/+48
| | | | | | | delimiter pairs and detect when we exceed the implementation limit for nesting depth, from Aaron Ballman! llvm-svn: 141782
* Fix "Uninitialized" warnings.NAKAMURA Takumi2011-10-081-2/+2
| | | | llvm-svn: 141487
* WhitespaceNAKAMURA Takumi2011-10-081-60/+60
| | | | llvm-svn: 141486
* Some fixes for MS-style asm parsing: specifically, add some error checking, ↵Eli Friedman2011-09-301-26/+105
| | | | | | and handle asm comments using semicolons correctly. (The comments are actually surprisingly tricky.) llvm-svn: 140837
* Changes to the name lookup have caused a regression in the digraph fix-it hint.Richard Trieu2011-09-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For instance: template <class T> void E() {}; class F {}; void test() { ::E<::F>(); E<::F>(); } Gives the following error messages: error: found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'? ::E<::F>(); ^~~ < :: error: expected expression E<::F>(); ^ error: expected ']' note: to match this '[' E<::F>(); This patch adds the digraph fix-it check right before the name lookup, moves the shared checking code to a new function, and adds new tests to catch future regressions. llvm-svn: 140039
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-2/+2
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Change references to StmtTy to Stmt and removed typedefs of StmtTy. Also ↵Richard Trieu2011-09-091-1/+1
| | | | | | removed typedef of AttrTy since it is not used. llvm-svn: 139349
* Change all references of type ExprTy to Expr and get rid of the typedefs.Richard Trieu2011-09-091-2/+2
| | | | llvm-svn: 139347
* When parsing a function-try-block that does not have aDouglas Gregor2011-09-071-1/+3
| | | | | | | | ctor-initializer, remember to call the Sema action to generate default ctor-initializers. What a delightful little miscompile. Fixes PR10578 / <rdar://problem/9877267>. llvm-svn: 139253
* PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept ↵Richard Smith2011-09-041-0/+3
| | | | | | for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class. llvm-svn: 139102
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-9/+13
| | | | | | | | | | | | | | Previously we would cut off the source file buffer at the code-completion point; this impeded code-completion inside C++ inline methods and, recently, with buffering ObjC methods. Have the code-completion inserted into the source buffer so that it can be buffered along with a method body. When we actually hit the code-completion point the cut-off lexing or parsing. Fixes rdar://10056932&8319466 llvm-svn: 139086
* Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This failsArgyrios Kyrtzidis2011-09-011-4/+2
| | | | | | in the face of buffering C++/ObjC method bodies. llvm-svn: 138972
* 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
OpenPOWER on IntegriCloud