summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Streamline BalancedDelimiterTracker, by eliminating the duplicateDouglas Gregor2012-03-081-50/+25
| | | | | | | | paren/brace/bracket tracking (the Consume* functions already did it), removing the use of ConsumeAnyToken(), and moving the hot paths inline with the error paths out-of-line. llvm-svn: 152274
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-4/+5
| | | | | | | | | | 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
* Change @import to @__experimental_modules_import. We are not ready to ↵Ted Kremenek2012-03-011-1/+1
| | | | | | | | commit to a particular syntax for modules, and don't have time to push it forward in the near future. llvm-svn: 151841
* Handle "#pragma GCC visibility" in a few more places. Switch over "#pragma ↵Eli Friedman2012-02-231-0/+3
| | | | | | | | 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
* Implement #pragma redefine_extname.David Chisnall2012-02-181-0/+5
| | | | | | This fixes PR5172 and allows clang to compile C++ programs on Solaris using the system headers. llvm-svn: 150881
* Allow thread safety attributes on function definitions.DeLesley Hutchins2012-02-161-2/+19
| | | | | | | | For compatibility with gcc, clang will now parse gcc attributes on function definitions, but issue a warning if the attribute is not a thread safety attribute. Warning controlled by -Wgcc-compat. llvm-svn: 150698
* Make parsing of objc @implementations more robust.Argyrios Kyrtzidis2012-02-071-4/+2
| | | | | | | | | | | | | | | | | | | Parsing of @implementations was based on modifying global state from the parser; the logic for late parsing of methods was spread in multiple places making it difficult to have a robust error recovery. -it was difficult to ensure that we don't neglect parsing the lexed methods. -it was difficult to setup the original objc container context for parsing the lexed methods after completing ParseObjCAtImplementationDeclaration and returning to top level context. Enhance parsing of @implementations by centralizing it in Parser::ParseObjCAtImplementationDeclaration(). ParseObjCAtImplementationDeclaration now returns only after an @implementation is fully parsed; all the data and logic for late parsing of methods is now in one place. This allows us to provide code-completion for late parsed methods with mis-matched braces. rdar://10775381 llvm-svn: 149987
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-061-3/+3
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Implement code completion support for module import declarations, e.g.,Douglas Gregor2012-01-291-0/+7
| | | | | | | | | | | | @import <complete with module names here> or @import std.<complete with submodule names here> Addresses <rdar://problem/10710117>. llvm-svn: 149199
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-4/+6
| | | | llvm-svn: 149127
* Avoid redundant NNS qualification in constructor/destructor names.Abramo Bagnara2012-01-271-0/+1
| | | | llvm-svn: 149124
* Fix our handling of #pragma GCC visibility.Rafael Espindola2012-01-261-0/+3
| | | | | | | | | | Now the lexer just produces a token and the parser is the one responsible for activating it. This fixes problem like the one pr11797 where the lexer and the parser were not in sync. This also let us be more strict on where in the file we accept these pragmas. llvm-svn: 149014
* Extend the error of invalid token after declarations to include fixits for Richard Trieu2012-01-191-14/+24
| | | | | | !=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =. llvm-svn: 148499
* Change the error when a '+=' follows a declaration to suggest a fixit to '=' ↵Richard Trieu2012-01-181-11/+14
| | | | | | | | | | | | | | | | | | | instead of just suggesting a ';'. Old error: plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration int x += 6; ^ ; New error: plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you mean '='? int x += 6; ^~ = llvm-svn: 148433
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-1/+0
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Improve diagnostics for dangling '}'.Nico Weber2012-01-171-1/+1
| | | | | | Fixes PR6484. Patch from Jason Switzer! llvm-svn: 148270
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* Eliminate the uglified keyword __import_module__ for importingDouglas Gregor2012-01-031-5/+1
| | | | | | | | | | | | | modules. This leaves us without an explicit syntax for importing modules in C/C++, because such a syntax needs to be discussed first. In Objective-C/Objective-C++, the @import syntax is used to import modules. Note that, under -fmodules, C/C++ programs can import modules via the #include mechanism when a module map is in place for that header. This allows us to work with modules in C/C++ without committing to a syntax. llvm-svn: 147467
* Introduce a non-uglified syntax for module imports in Objective-C:Douglas Gregor2012-01-031-4/+5
| | | | | | @import identifier [. identifier]* ; llvm-svn: 147452
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-5/+4
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-2/+2
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* Pass context and access to Parser::ParseExplicitInstantiation() forArgyrios Kyrtzidis2011-12-231-1/+2
| | | | | | | | good parser error recovery and for not crashing. We still have a accepts-invalid-code bug. llvm-svn: 147216
* In Parser::SkipUntil do not stop at '@' unconditionally.Argyrios Kyrtzidis2011-12-171-3/+0
| | | | | | | | | | | | | | | Stopping at '@' was originally intended to avoid skipping an '@' at the @interface context when doing parser recovery, but we should not stop at all '@' tokens because they may be part of expressions (e.g. in @"string", @selector(), etc.), so in most cases we will want to skip them. This commit caused 'test/Parser/method-def-in-class.m' to fail for the cases where we tried to recover from unmatched angle bracket but IMO it is not a big deal to not have good recovery from such broken code and the way we did recovery would not always work anyway (e.g. if there was '@' in an expression). The case that rdar://7029784 is about still passes. llvm-svn: 146815
* Remove unused parameter from the LateParsedTemplatedFunction constructor.Francois Pichet2011-12-081-1/+1
| | | | llvm-svn: 146145
* Support decltype in nested-name-specifiers.David Blaikie2011-12-041-4/+4
| | | | llvm-svn: 145785
* Diagnose use of wide string literal in 'asm' instead of crashing. Fixes ↵Ted Kremenek2011-12-021-5/+12
| | | | | | <rdar://problem/10465079>. llvm-svn: 145656
* Switch the module-loading interfaces and parser from a simpleDouglas Gregor2011-11-301-9/+22
| | | | | | | top-level module name to a module path (e.g., std.vector). We're still missing a number of pieces for this actually to do something. llvm-svn: 145462
* Fix leaking of LexedMethod objects created for caching objc method ↵Argyrios Kyrtzidis2011-11-291-0/+2
| | | | | | | | definitions tokens for late parsing. llvm-svn: 145394
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-071-1/+1
| | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. llvm-svn: 144011
* Tighten up the conditions under which we consider ourselves to beDouglas Gregor2011-11-071-2/+4
| | | | | | | entering the context of a nested-name-specifier. Fixes <rdar://problem/10397846>. llvm-svn: 143967
* Check for unexpanded parameter packs in the name that guards aDouglas Gregor2011-10-251-1/+5
| | | | | | | | | Microsoft __if_exists/__if_not_exists statement. Also note that we weren't traversing DeclarationNameInfo *at all* within the RecursiveASTVisitor, which would be rather fatal for variadic templates. llvm-svn: 142906
* Rework Microsoft __if_exists/__if_not_exists parsing and semanticDouglas Gregor2011-10-241-33/+48
| | | | | | | | | | | | | | | | | 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-0/+10
| | | | | | | keyword, because both libstdc++ and libc++ use "__except" as an identifier. Fixes <rdar://problem/10322555>. llvm-svn: 142636
* 'extern template' is a C++11 feature. Add an Extension for C++98 (this matchesRichard Smith2011-10-201-0/+3
| | | | | | gcc's behaviour), and a -Wc++98-compat-pedantic warning for C++11. llvm-svn: 142597
* Implement -Wc++98-compat warnings for the parser.Richard Smith2011-10-151-7/+9
| | | | llvm-svn: 142056
* Introduce BalancedDelimiterTracker, to better track open/closeDouglas Gregor2011-10-121-37/+70
| | | | | | | delimiter pairs and detect when we exceed the implementation limit for nesting depth, from Aaron Ballman! llvm-svn: 141782
* Add typo correction for type names.Kaelyn Uhrain2011-10-111-2/+7
| | | | | | | | The main motivation was to do typo correction in C++ "new" statements, though picking it up in other places where type names are expected was pretty much a freebie. llvm-svn: 141621
* Move some bool flags out of function parameter lists.Kaelyn Uhrain2011-10-111-2/+2
| | | | llvm-svn: 141610
* Revert r140589. It was causing failures during llvm compilation:Bill Wendling2011-09-271-6/+1
| | | | | | | | | | | | | | llvm[1]: Compiling CommandLine.cpp for Debug+Asserts build if /Users/void/llvm/llvm-opt.obj/Release+Asserts/bin/clang++ -I/Users/void/llvm/llvm.obj/include -I/Users/void/llvm/llvm.obj/lib/Support -I/Users/void/llvm/llvm.src/include -I/Users/void/llvm/llvm.src/lib/Support -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -Wcast-qual -m64 -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d" /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp -o /Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o ; \ then /bin/mv -f "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d"; else /bin/rm "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp"; exit 1; fi In file included from /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp:25: /Users/void/llvm/llvm.src/include/llvm/Support/system_error.h:690:14: error: unknown type name 'make_error_condition'; did you mean 'error_condition'? {*this = make_error_condition(_e);} ^~~~~~~~~~~~~~~~~~~~ error_condition ... llvm-svn: 140599
* Add typo correction for the type name in C++ "new" statementsKaelyn Uhrain2011-09-271-1/+6
| | | | llvm-svn: 140589
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-1/+1
| | | | | | | | 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
* Implement the Objective-C 'instancetype' type, which is an alias ofDouglas Gregor2011-09-081-0/+1
| | | | | | | | | | 'id' that can be used (only!) via a contextual keyword as the result type of an Objective-C message send. 'instancetype' then gives the method a related result type, which we have already been inferring for a variety of methods (new, alloc, init, self, retain). Addresses <rdar://problem/9267640>. llvm-svn: 139275
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-6/+18
| | | | | | | | | | | | | | 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
* Switch __import__ over to __import_module__, so we don't conflict withDouglas Gregor2011-08-311-2/+3
| | | | | | | | existing practice with Python extension modules. Not that Python extension modules should be using a double-underscored identifier anyway, but... llvm-svn: 138870
* objective-c: Treat top-level objective-c declarationsFariborz Jahanian2011-08-271-4/+1
| | | | | | | | | | , such as list of forward @class decls, in a DeclGroup node. Deal with its consequence throught clang. This is in preparation for more Sema work ahead. // rdar://8843851. Feel free to reverse if it breaks something important and I am unavailable. llvm-svn: 138709
* Introduce support for a simple module import declaration, whichDouglas Gregor2011-08-261-0/+24
| | | | | | | | | | | | | | | | | | | | | | loads the named module. The syntax itself is intentionally hideous and will be replaced at some later point with something more palatable. For now, we're focusing on the semantics: - Module imports are handled first by the preprocessor (to get macro definitions) and then the same tokens are also handled by the parser (to get declarations). If both happen (as in normal compilation), the second one is redundant, because we currently have no way to hide macros or declarations when loading a module. Chris gets credit for this mad-but-workable scheme. - The Preprocessor now holds on to a reference to a module loader, which is responsible for loading named modules. CompilerInstance is the only important module loader: it now knows how to create and wire up an AST reader on demand to actually perform the module load. - We search for modules in the include path, using the module name with the suffix ".pcm" (precompiled module) for the file name. This is a temporary hack; we hope to improve the situation in the future. llvm-svn: 138679
* Reverse r138567 until a buildbot failure is investigated.Fariborz Jahanian2011-08-251-1/+4
| | | | llvm-svn: 138584
* objc -arse: Use DeclGroup for forward class declarations;Fariborz Jahanian2011-08-251-4/+1
| | | | | | as in @class foo, bar. More cleanup to follow. llvm-svn: 138567
* objc - Simplify switing objc decl context by usingFariborz Jahanian2011-08-221-10/+6
| | | | | | a context switching object. llvm-svn: 138248
* Restore patch I reversed in r138040. Known buildbotFariborz Jahanian2011-08-221-1/+10
| | | | | | failures are resolved. llvm-svn: 138234
OpenPOWER on IntegriCloud