summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Parser: Add support for #pragma align, which is just another spelling of #pragmaDaniel Dunbar2010-07-311-0/+5
| | | | | | options align. llvm-svn: 109952
* Modify the pragma handlers to accept and use StringRefs instead of ↵Argyrios Kyrtzidis2010-07-131-21/+15
| | | | | | | | | | | IdentifierInfos. When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded). We can avoid this if we just use StringRefs for the pragmas. As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified. llvm-svn: 108237
* revert a hunk of code that Argiris added in r106213, which is theChris Lattner2010-07-121-10/+1
| | | | | | | root cause of PR7481 and probably more, and has no apparent testcases. I don't understand the logic here so I can't repair it. llvm-svn: 108119
* Fix PR7617 by not entering ParseFunctionDefinition whenChris Lattner2010-07-111-4/+9
| | | | | | | | | | | | | | | | | | | | | a function prototype is followed by a declarator if we aren't parsing a K&R style identifier list. Also, avoid skipping randomly after a declaration if a semicolon is missing. Before we'd get: t.c:3:1: error: expected function body after function declarator void bar(); ^ Now we get: t.c:1:11: error: invalid token after top level declarator void foo() ^ ; llvm-svn: 108105
* add a const qualifier, refactor some code.Chris Lattner2010-07-111-1/+1
| | | | llvm-svn: 108104
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-29/+30
| | | | | | | | | | | | | | 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-1/+12
| | | | | | | | | | | 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
* Fix the recently-added warning about 'typename' and 'template'Douglas Gregor2010-06-161-2/+4
| | | | | | | | | disambiguation keywords outside of templates in C++98/03. Previously, the warning would fire when the associated nested-name-specifier was not dependent, but that was a misreading of the C++98/03 standard: now, we complain only when we're outside of any template. llvm-svn: 106161
* Parse: Add support for '#pragma options align'.Daniel Dunbar2010-05-261-0/+7
| | | | | | Also, fix a source location bug with the rparen in #pragma pack. llvm-svn: 104784
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-251-3/+23
| | | | | | | | | | | 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 we encounter a dependent template nameDouglas Gregor2010-05-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is missing the 'template' keyword, e.g., t->getAs<T>() where getAs is a member of an unknown specialization. C++ requires that we treat "getAs" as a value, but that would fail to parse since T is the name of a type. We would then fail at the '>', since a type cannot be followed by a '>'. This is a very common error for C++ programmers to make, especially since GCC occasionally allows it when it shouldn't (as does Visual C++). So, when we are in this case, we use tentative parsing to see if the tokens starting at "<" can only be parsed as a template argument list. If so, we produce a diagnostic with a fix-it that states that the 'template' keyword is needed: test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword is required to treat 'getAs' as a dependent template name t->getAs<T>(); ^ template This is just a start of this patch; I'd like to apply the same approach to everywhere that a template-id with dependent template name can be parsed. llvm-svn: 104406
* Propagate access specifiers to anonymous union members nested within classes.John McCall2010-05-211-1/+1
| | | | | | Fixes <rdar://problem/7987650>. llvm-svn: 104376
* Diagnose misordered initializers in constructor templates immediately instead ofJohn McCall2010-04-101-2/+8
| | | | | | | | | | when they're instantiated. Merge the note into the -Wreorder warning; it doesn't really contribute much, and it was splitting a thought across diagnostics anyway. Don't crash in the parser when a constructor's initializers end in a comma and there's no body; the recovery here is still terrible, but anything's better than a crash. llvm-svn: 100922
* Fix some redundant errors by changing CXXScopeSpec::isSet calls intoJeffrey Yasskin2010-04-071-1/+1
| | | | | | isNotEmpty calls. llvm-svn: 100722
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-5/+5
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-5/+5
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-5/+5
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Remove the capture, serialization, and deserialization of commentDouglas Gregor2010-03-191-18/+0
| | | | | | | | ranges as part of the ASTContext. This code is not and was never used, but contributes ~250k to the size of the Cocoa.h precompiled header. llvm-svn: 99007
* Unbreak the buildDouglas Gregor2010-03-011-1/+1
| | | | llvm-svn: 97519
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Fix an assertion-on-error during tentative constructor parsing byJohn McCall2010-02-261-20/+20
| | | | | | | | | | propagating error conditions out of the various annotate-me-a-snowflake routines. Generally (but not universally) removes redundant diagnostics as well as, you know, not crashing on bad code. On the other hand, I have just signed myself up to fix fiddly parser errors for the next week. Again. llvm-svn: 97221
* Retain attributes for K&R style parameter declarations.Richard Pennington2010-02-231-4/+5
| | | | llvm-svn: 96941
* Clean up ownership of 'AttributeList' objects in Parser. ApparentlyTed Kremenek2010-02-111-2/+2
| | | | | | | | | | | | | | | | | | | | | we would just leak them all over the place, with no clear ownership of these objects at all. AttributeList objects would get leaked on both error and non-error paths. Note: I introduced the usage of llvm::OwningPtr<AttributeList> to manage these objects, which is particularly useful for methods with multiple return sites. In at least one method I used them even when they weren't strictly necessary because it clarified the ownership semantics and made the code easier to read. Should the excessive 'take()' and 'reset()' calls become a performance issue we can always re-evaluate. Note+1: I believe I have not introduced any double-frees, but it would be nice for someone to review this. This fixes <rdar://problem/7635046>. llvm-svn: 95847
* When placing an annotation token over an existing annotation token, make ↵Sebastian Redl2010-02-081-1/+2
| | | | | | sure that the new token's range extends to the end of the old token. Assert that in AnnotateCachedTokens. Fixes PR6248. llvm-svn: 95555
* Fix assertion failure when parsing linkage specifications (PR5921),Douglas Gregor2010-02-071-1/+0
| | | | | | from Keir Mierle! llvm-svn: 95516
* First stage of adding AltiVec supportJohn Thompson2010-02-051-0/+5
| | | | llvm-svn: 95335
* Fixit to remove 'volatile' in file-scope 'asm volatile'.John McCall2010-01-251-1/+6
| | | | llvm-svn: 94466
* Warn on top-level 'asm volatile' (instead of misparsing it).John McCall2010-01-251-0/+5
| | | | | | "Fixes" rdar://problem/7574870 llvm-svn: 94458
* allow the HandlerComment callback to push tokens into theChris Lattner2010-01-181-1/+2
| | | | | | | preprocessor. This could be used by an OpenMP implementation or something. Patch by Abramo Bagnara! llvm-svn: 93795
* Whenever completing ordinary names for an Objective-C source, alsoDouglas Gregor2010-01-131-1/+3
| | | | | | | | | | | provide completions for @ keywords. Previously, we only provided @-completions after an @ was actually typed, which is useful but probably not the common case. Also, make sure a few Objective-C 2.0 completions only show up when Objective-C 2.0 support is enabled (the default). llvm-svn: 93354
* Reimplement constructor declarator parsing to cope with template-idsDouglas Gregor2010-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that name constructors, the endless joys of out-of-line constructor definitions, and various other corner cases that the previous hack never imagined. Fixes PR5688 and tightens up semantic analysis for constructor names. Additionally, fixed a problem where we wouldn't properly enter the declarator scope of a parenthesized declarator. We were entering the scope, then leaving it when we saw the ")"; now, we re-enter the declarator scope before parsing the parameter list. Note that we are forced to perform some tentative parsing within a class (call it C) to tell the difference between C(int); // constructor and C (f)(int); // member function which is rather unfortunate. And, although it isn't necessary for correctness, we use the same tentative-parsing mechanism for out-of-line constructors to improve diagnostics in icky cases like: C::C C::f(int); // error: C::C refers to the constructor name, but // we complain nicely and recover by treating it as // a type. llvm-svn: 93322
* Improve code completion by introducing patterns for the various C andDouglas Gregor2010-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | C++ grammatical constructs that show up in top-level (namespace-level) declarations, member declarations, template declarations, statements, expressions, conditions, etc. For example, we now provide a pattern for static_cast<type>(expr) when we can have an expression, or using namespace identifier; when we can have a using directive. Also, improves the results of code completion at the beginning of a top-level declaration. Previously, we would see value names (function names, global variables, etc.); now we see types, namespace names, etc., but no values. llvm-svn: 93134
* Teach TryAnnotateTypeOrScopeToken to deal with already-annotatedJohn McCall2009-12-191-4/+9
| | | | | | | scope specifiers. Fix a tentative parsing bug that came up in LLVM. Incidentally fixes some random FIXMEs in an existing testcase. llvm-svn: 91734
* refactor the 'ColonIsSacred' argument to ParseOptionalCXXScopeSpecifierChris Lattner2009-12-101-1/+2
| | | | | | | to be a bool in Parser that is twiddled by the ColonProtectionRAIIObject class. No functionality change. llvm-svn: 91014
* rename ExtensionRAIIObject.h -> RAIIObjectsForParser.hChris Lattner2009-12-101-1/+1
| | | | llvm-svn: 91008
* Fixes a bogus error when declaring an extern "C" array.Fariborz Jahanian2009-12-091-3/+10
| | | | | | (fixes radar 7457109). llvm-svn: 90986
* fix a crash on invalid I found when working on something unrelated.Chris Lattner2009-12-071-1/+3
| | | | llvm-svn: 90729
* simplify logic.Chris Lattner2009-12-061-6/+7
| | | | llvm-svn: 90712
* remove some extraneous syntax: sourceloc implicitly converts to sourcerange.Chris Lattner2009-12-061-1/+1
| | | | llvm-svn: 90710
* Added rudimentary C++0x attribute support.Alexis Hunt2009-11-211-8/+19
| | | | | | | | | | | | | | The following attributes are currently supported in C++0x attribute lists (and in GNU ones as well): - align() - semantics believed to be conformant to n3000, except for redeclarations and what entities it may apply to - final - semantics believed to be conformant to CWG issue 817's proposed wording, except for redeclarations - noreturn - semantics believed to be conformant to n3000, except for redeclarations - carries_dependency - currently ignored (this is an optimization hint) llvm-svn: 89543
* Improve parsing of template arguments to lay the foundation forDouglas Gregor2009-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | handling template template parameters properly. This refactoring: - Parses template template arguments as id-expressions, representing the result of the parse as a template name (Action::TemplateTy) rather than as an expression (lame!). - Represents all parsed template arguments via a new parser-specific type, ParsedTemplateArgument, which stores the kind of template argument (type, non-type, template) along with all of the source information about the template argument. This replaces an ad hoc set of 3 vectors (one for a void*, which was either a type or an expression; one for a bit telling whether the first was a type or an expression; and one for a single source location pointing at the template argument). - Moves TemplateIdAnnotation into the new Parse/Template.h. It never belonged in the Basic library anyway. llvm-svn: 86708
* Change our basic strategy for avoiding deprecation warnings when the decl useJohn McCall2009-11-041-2/+13
| | | | | | | | | | | | appears in a deprecated context. In the new strategy, we emit the warnings as usual unless we're currently parsing a declaration, where "declaration" is restricted to mean a decl group or a few special cases in Objective C. If we *are* parsing a declaration, we queue up the deprecation warnings until the declaration has been completely parsed, and then emit them only if the decl is not deprecated. We also standardize the bookkeeping for deprecation so as to avoid special cases. llvm-svn: 85998
* Implement support for parsing dependent template-ids that refer toDouglas Gregor2009-11-041-2/+5
| | | | | | | | overloaded operators, e.g., p->template operator+<T>() llvm-svn: 85989
* Parsing and semantic analysis for template-ids that name overloadedDouglas Gregor2009-11-031-2/+3
| | | | | | | | | | | | operators, e.g., operator+<int> which now works in declarators, id-expressions, and member access expressions. This commit only implements the non-dependent case, where we can resolve the template-id to an actual declaration. llvm-svn: 85966
* Silence a warning by giving Parser::FieldCallback a virtual destructor, andJohn McCall2009-11-031-0/+7
| | | | | | anchor the vtable to Parser.cpp for good measure. llvm-svn: 85927
* Reorganize the parsing of decl groups / function definitions so thatJohn McCall2009-11-031-48/+2
| | | | | | | declarators are parsed primarily within a single function (at least for these cases). Remove some excess diagnostics arising during parse failures. llvm-svn: 85924
* Don't crash when dumping pretty stack traces, if the current tok is anDaniel Dunbar2009-10-171-1/+4
| | | | | | | | annotation token. - I'm not sure what the best thing to print is, for now we just print the token location and 'at annotation token'. llvm-svn: 84312
* Code completion for ordinary names when we're starting a declaration, ↵Douglas Gregor2009-09-211-0/+4
| | | | | | expression, or statement llvm-svn: 82481
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-46/+46
| | | | llvm-svn: 81346
* Parse extern templates, pass that information all the way to Sema,Douglas Gregor2009-09-041-0/+15
| | | | | | then drop it on the floor. llvm-svn: 80989
OpenPOWER on IntegriCloud