summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Empty enum in c is now error to match gcc's behavior.Fariborz Jahanian2010-05-281-1/+1
| | | | | | (radar 8040068). llvm-svn: 105011
* 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
* Propagate access specifiers to anonymous union members nested within classes.John McCall2010-05-211-2/+3
| | | | | | Fixes <rdar://problem/7987650>. llvm-svn: 104376
* Added basic source locations to Elaborated and DependentName types.Abramo Bagnara2010-05-191-1/+1
| | | | llvm-svn: 104169
* Add support for Microsoft's __thiscall, from Steven Watanabe!Douglas Gregor2010-05-181-4/+9
| | | | llvm-svn: 104026
* Improve error recovery in C/ObjC when the first argument of a functionChris Lattner2010-05-141-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | declarator is incorrect. Not being a typename causes the parser to dive down into the K&R identifier list handling stuff, which is almost never the right thing to do. Before: r.c:3:17: error: expected ')' void bar(intptr y); ^ r.c:3:9: note: to match this '(' void bar(intptr y); ^ r.c:3:10: error: a parameter list without types is only allowed in a function definition void bar(intptr y); ^ After: r.c:3:10: error: unknown type name 'intptr'; did you mean 'intptr_t'? void bar(intptr y); ^~~~~~ intptr_t r.c:1:13: note: 'intptr_t' declared here typedef int intptr_t; ^ This fixes rdar://7980651 - poor recovery for bad type in the first arg of a C function llvm-svn: 103783
* Refactor ParseFunctionDeclaratorIdentifierList to have the firstChris Lattner2010-05-141-11/+18
| | | | | | | identifier in the identifier list consumed before it is called. No functionality change. llvm-svn: 103781
* It's okay to reference an enum in a template definition, even thoughDouglas Gregor2010-05-031-9/+12
| | | | | | it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>. llvm-svn: 102926
* Be more careful around dependent nested-name-specifiers, complainingDouglas Gregor2010-04-241-4/+38
| | | | | | | | when they are not complete (since we could not match them up to anything) and ensuring that enum parsing can cope with dependent elaborated-type-specifiers. Fixes PR6915 and PR6649. llvm-svn: 102247
* Make Parser::ConsumeAndStoreUntil() more consistent with Parser::SkipUntil().Argyrios Kyrtzidis2010-04-231-1/+2
| | | | | | | | | ConsumeAndStoreUntil would stop at tok::unknown when caching an inline method definition while SkipUntil would go past it while parsing the method. Fixes PR 6903. llvm-svn: 102214
* Audit uses of Sema::LookupSingleName for those lookups that areDouglas Gregor2010-04-151-0/+5
| | | | | | | | | | | intended for redeclarations, fixing those that need it. Fixes PR6831. This uncovered an issue where the C++ type-specifier-seq parsing logic would try to perform name lookup on an identifier after it already had a type-specifier, which could also lead to spurious ambiguity errors (as in PR6831, but with a different test case). llvm-svn: 101419
* Parse constructor names in friend declarations. Part of the fix forJohn McCall2010-04-131-8/+16
| | | | | | PR6207. llvm-svn: 101119
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-7/+8
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Fix some redundant errors by changing CXXScopeSpec::isSet calls intoJeffrey Yasskin2010-04-071-1/+1
| | | | | | isNotEmpty calls. llvm-svn: 100722
* fix PR6782, an accept invalid. We weren't emitting the diagnostic Chris Lattner2010-04-051-7/+10
| | | | | | returned by SetTypeSpecType. llvm-svn: 100443
* 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
* Make sure we actually override ReadHeaderFileInfo when we meant toDouglas Gregor2010-03-161-1/+1
| | | | llvm-svn: 98655
* Diagnose the declaration of enum templates. Also, be a bit moreDouglas Gregor2010-03-021-3/+13
| | | | | | careful about value-dependent enumerators. Fixes PR5786. llvm-svn: 97570
* Robustify instantiation of templates when there are errors in theDouglas Gregor2010-03-011-4/+4
| | | | | | | | | template definition. Do this both by being more tolerant of errors in our asserts and by not dropping a variable declaration completely when its initializer is ill-formed. Fixes the crash-on-invalid in PR6375, but not the original issue. llvm-svn: 97463
* Don't infinite-loop if TryAnnotateCXXScopeToken fails to annotate but doesn'tJohn McCall2010-03-011-0/+2
| | | | | | | | | signal an error. This can happen even when the current token is '::' if this is a ::new or ::delete expression. This was an oversight in my recent parser refactor; fixes PR 5825. llvm-svn: 97462
* pull some altivec stuff out of line.Chris Lattner2010-02-281-0/+66
| | | | llvm-svn: 97405
* Implement PR6423 by using one token of lookahead to disambiguate Chris Lattner2010-02-281-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | an *almost* always incorrect case. This only does the lookahead in the insanely unlikely case, so it shouldn't impact performance. On this testcase: struct foo { } typedef int x; Before: t.c:3:9: error: cannot combine with previous 'struct' declaration specifier typedef int x; ^ After: t.c:2:2: error: expected ';' after struct } ^ ; llvm-svn: 97403
* Fix an assertion-on-error during tentative constructor parsing byJohn McCall2010-02-261-36/+60
| | | | | | | | | | 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
* Only parse C++0x attribute specifiers in declarators when in C++0xDouglas Gregor2010-02-191-1/+1
| | | | | | | mode. This allows us to detect invalid VLAs in Objective-C++ mode. This should be the last of <rdar://problem/7660386>. llvm-svn: 96679
* Improve the diagnostic given when referring to a tag type without a tag (in C)John McCall2010-02-141-1/+1
| | | | | | | | | or that's been hidden by a non-type (in C++). The ideal C++ diagnostic here would note the hiding declaration, but this is a good start. llvm-svn: 96141
* Clean up ownership of 'AttributeList' objects in Parser. ApparentlyTed Kremenek2010-02-111-14/+15
| | | | | | | | | | | | | | | | | | | | | 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
* First stage of adding AltiVec supportJohn Thompson2010-02-051-3/+32
| | | | llvm-svn: 95335
* In some contexts, type declarations cannot occur. Pass this information down ↵Sebastian Redl2010-02-031-4/+6
| | | | | | to ParseClassSpecifier, to make its decision easier. Fixes PR6200. llvm-svn: 95255
* improve diagnostics on missing ; in a struct. Before:Chris Lattner2010-02-021-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | t.c:4:3: error: expected ';' at end of declaration list int y; ^ t.c:4:8: warning: extra ';' inside a struct or union int y; ^ t.c:6:1: warning: expected ';' at end of declaration list }; ^ After: t.c:3:8: error: expected ';' at end of declaration list int x // expected-error {{expected ';' at end of declaration list}} ^ ; t.c:5:8: warning: expected ';' at end of declaration list int z ^ ; llvm-svn: 95038
* Move the type specifier location for elaborated-type-specifiers fromDouglas Gregor2010-01-251-2/+4
| | | | | | | the tag kind (union, struct, class, enum) over to the name of the tag, if there is a name, since most clients want to point at the name. llvm-svn: 94424
* 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
* Add type source information for both kinds of typeof types.John McCall2010-01-131-0/+4
| | | | | | Patch by Enea Zaffanella. llvm-svn: 93344
* Reimplement constructor declarator parsing to cope with template-idsDouglas Gregor2010-01-131-18/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+8
| | | | | | | | | | | | | | | | | | | | | | 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
* Fix 80-col violation.Zhongxing Xu2009-12-281-1/+1
| | | | llvm-svn: 92204
* Enter the scope of an initializer for direct-initialization as well asDouglas Gregor2009-12-221-0/+16
| | | | | | for copy-initialization. llvm-svn: 91909
* Just push a new scope when parsing an out-of-line variable definition.John McCall2009-12-191-2/+6
| | | | | | | Magically fixes all the terrible lookup problems associated with not pushing a new scope. Resolves an ancient xfail and an LLVM misparse. llvm-svn: 91769
* Remember the type name's scope specifier in the DeclSpec.John McCall2009-12-121-8/+9
| | | | llvm-svn: 91215
* Don't enter a new scope for a namespace-qualified declarator unless we'reJohn McCall2009-12-111-3/+4
| | | | | | | in a file context. In well-formed code, only happens with friend functions. Fixes PR 5760. llvm-svn: 91146
* fix incorrect parsing of bitfields pointed out by Doug. I choseChris Lattner2009-12-101-2/+4
| | | | | | | to use ColonProtectionRAIIObject in the C codepath even though it won't matter for consistency. llvm-svn: 91037
* rename ExtensionRAIIObject.h -> RAIIObjectsForParser.hChris Lattner2009-12-101-1/+1
| | | | llvm-svn: 91008
* remove some extraneous syntax: sourceloc implicitly converts to sourcerange.Chris Lattner2009-12-061-2/+2
| | | | llvm-svn: 90710
* Added rudimentary C++0x attribute support.Alexis Hunt2009-11-211-35/+91
| | | | | | | | | | | | | | 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
* Parse C++0x constexpr. Test case follows when this does something useful.Sebastian Redl2009-11-051-0/+6
| | | | llvm-svn: 86135
* Change our basic strategy for avoiding deprecation warnings when the decl useJohn McCall2009-11-041-4/+11
| | | | | | | | | | | | 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
* CFieldCallback doesn't need to create an ExtensionRAIIObject: it's actuallyJohn McCall2009-11-031-14/+3
| | | | | | | automatically shadowed by the ExtensionRAIIObject created by ParseStructDeclaration. llvm-svn: 85941
OpenPOWER on IntegriCloud