summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a bug in the token caching for inline constructors in C++11, and improve ↵Sebastian Redl2011-09-301-13/+8
| | | | | | error recovery in both dialects. This should fix the GCC test suite failures as well. llvm-svn: 140847
* Correctly parse braced member initializers (even in delayed parsing) and ↵Sebastian Redl2011-09-241-1/+1
| | | | | | | | | | | correctly pass the information on to Sema. There's still an incorrectness in the way template instantiation works now, but that is due to a far larger underlying representational problem. Also add a test case for various list initialization cases of scalars, which test this commit as well as the previous one. llvm-svn: 140460
* Fix wrong comment about reentering template scope for ↵Francois Pichet2011-09-231-1/+1
| | | | | | -fdelayed-template-parsing. llvm-svn: 140382
* [microsoft] Fix a bug in -fdelayed-template-parsing mode where we were not ↵Francois Pichet2011-09-221-19/+38
| | | | | | | | | | reentering the delayed function context correctly. The problem was that all template params were reintroduced inside the same scope. So if we had a situation where we had 2 template params with the same name at different scope then clang would generate an error about ambiguous name. The solution is to create a new ParseScope(Scope::TemplateParamScope) for each template scope that we want to reenter. (from the outmost to the innermost scope) This fixes some errors when parsing MFC code with clang. llvm-svn: 140344
* Changed references of BaseTy, MemInitTy, CXXScopeTy, TemplateParamsTy to ↵Richard Trieu2011-09-091-1/+1
| | | | | | CXXBaseSpecifier, CXXCtorInitializer, NestedNameSpecifier, TemplateParameterList and removed their typedefs. llvm-svn: 139350
* objc - Simplify switing objc decl context by usingFariborz Jahanian2011-08-221-11/+4
| | | | | | a context switching object. llvm-svn: 138248
* Restore patch I reversed in r138040. Known buildbotFariborz Jahanian2011-08-221-5/+14
| | | | | | failures are resolved. llvm-svn: 138234
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-4/+4
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Introduce DelayedCleanupPool useful for simplifying clean-up of certain ↵Argyrios Kyrtzidis2011-06-221-3/+1
| | | | | | | | | | resources that, while their lifetime is well-known and restricted, cleaning them up manually is easy to miss and cause a leak. Use it to plug the leaking of TemplateIdAnnotation objects. rdar://9634138. llvm-svn: 133610
* Implement support for C++0x alias templates.Richard Smith2011-05-051-4/+4
| | | | llvm-svn: 130953
* Remove unnecessary const away cast in LateTemplateParserCallback.Francois Pichet2011-04-231-2/+2
| | | | llvm-svn: 130058
* Add -fdelayed-template-parsing option. Using this option all templated ↵Francois Pichet2011-04-221-0/+124
| | | | | | | | | function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup. Using this flag is necessary for compatibility with Microsoft template code. This also provides some parsing speed improvement. llvm-svn: 130022
* Insomniac refactoring: change how the parser allocates attributes so thatJohn McCall2011-03-241-3/+3
| | | | | | | | | 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
* Push nested-name-specifier source-location information into dependentDouglas Gregor2011-03-021-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | template specialization types. This also required some parser tweaks, since we were losing track of the nested-name-specifier's source location information in several places in the parser. Other notable changes this required: - Sema::ActOnTagTemplateIdType now type-checks and forms the appropriate type nodes (+ source-location information) for an elaborated-type-specifier ending in a template-id. Previously, we used a combination of ActOnTemplateIdType and ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped around a DependentTemplateSpecializationType, which duplicated the keyword ("class", "struct", etc.) and nested-name-specifier storage. - Sema::ActOnTemplateIdType now gets a nested-name-specifier, which it places into the returned type-source location information. - Sema::ActOnDependentTag now creates types with source-location information. llvm-svn: 126808
* Retain complete source-location information for C++Douglas Gregor2011-02-241-1/+1
| | | | | | | | | | | | nested-name-specifiers throughout the parser, and provide a new class (NestedNameSpecifierLoc) that contains a nested-name-specifier along with its type-source information. Right now, this information is completely useless, because we don't actually store the source-location information anywhere in the AST. Call this Step 1/N. llvm-svn: 126391
* When parsing an out-of-line member function declaration, we must delayJohn McCall2011-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | access-control diagnostics which arise from the portion of the declarator following the scope specifier, just in case access is granted by friending the individual method. This can also happen with in-line member function declarations of class templates due to templated-scope friend declarations. We were really playing fast-and-loose before with this sort of thing, and it turned out to work because *most* friend functions are in file scope. Making us delay regardless of context exposed several bugs with how we were manipulating delay. I ended up needing a concept of a context that's independent of the declarations in which it appears, and then I actually had to make some things save contexts correctly, but delay should be much cleaner now. I also encapsulated all the delayed-diagnostics machinery in a single subobject of Sema; this is a pattern we might want to consider rolling out to other components of Sema. llvm-svn: 125485
* Implement the suggested resolution to core issue 547, extended to alsoDouglas Gregor2011-01-311-1/+2
| | | | | | | | | allow ref-qualifiers on function types used as template type arguments. GNU actually allows cv-qualifiers on function types in many places where it shouldn't, so we currently categorize this as a GNU extension. llvm-svn: 124584
* Downgrade the "variadic templates are a C++0x feature" error to anDouglas Gregor2011-01-191-2/+2
| | | | | | | | ExtWarn. We want variadic templates to be usable in libc++/libstdc++ headers even when we're in C++98/03 mode, since it's the only clean way to implement TR1 <functional>. llvm-svn: 123852
* Fix warnings found by gcc-4.6, from -Wunused-but-set-variable andJeffrey Yasskin2011-01-181-3/+1
| | | | | | -Wint-to-pointer-cast. llvm-svn: 123719
* Make sure that we parse a '>>' that closes two template argument listsDouglas Gregor2011-01-111-1/+1
| | | | | | appropritely when there are no other template arguments. llvm-svn: 123204
* Parse template template argument pack expansions. They're still notDouglas Gregor2011-01-051-5/+18
| | | | | | implemented, however. llvm-svn: 122888
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-9/+22
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-6/+4
| | | | | | | 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
* Introduce a new type, PackExpansionType, to capture types that areDouglas Gregor2010-12-201-0/+5
| | | | | | | | | | | | | | | | | | | | pack expansions, e.g. given template<typename... Types> struct tuple; template<typename... Types> struct tuple_of_refs { typedef tuple<Types&...> types; }; the type of the "types" typedef is a PackExpansionType whose pattern is Types&. This commit introduces support for creating pack expansions for template type arguments, as above, but not for any other kind of pack expansion, nor for any form of instantiation. llvm-svn: 122223
* Diagnose attempst to template using declarations and using directives.John McCall2010-11-101-2/+21
| | | | | | Recover from the latter and fail early for the former. Fixes PR8022. llvm-svn: 118669
* Diagnose the declaration of template template parameters thatDouglas Gregor2010-10-211-1/+1
| | | | | | | | themselves have no template parameters. This is actually a restriction due to the grammar of template template parameters, but we choose to diagnose it in Sema to provide better recovery. llvm-svn: 117032
* When we are missing the ',' or '>' to terminate a template parameterDouglas Gregor2010-10-151-1/+1
| | | | | | list, complain about it! Fixes PR7053. llvm-svn: 116551
* One who seeks knowledge learns something new every day.John McCall2010-08-261-2/+2
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-2/+2
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-9/+11
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-1/+1
| | | | llvm-svn: 111863
* Push DeclGroupRefs and TemplateNames in an opaque but type-safe wayJohn McCall2010-08-231-2/+2
| | | | | | through the parser. llvm-svn: 111800
* Kill off Parser::TemplateParameterList to avoid misparses.John McCall2010-08-231-4/+4
| | | | llvm-svn: 111796
* Sundry incremental steps towards killing off Action.John McCall2010-08-231-1/+1
| | | | llvm-svn: 111795
* DeclPtrTy -> Decl *John McCall2010-08-211-27/+25
| | | | llvm-svn: 111733
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-3/+3
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Template keyword should not be ignored building a QualifiedTemplateName.Abramo Bagnara2010-08-061-1/+3
| | | | llvm-svn: 110441
* Treat template parameters as part of the declaration-specifiers for theJohn McCall2010-07-161-3/+14
| | | | | | | | purpose of access control. Fixes PR7644. I can't actually find anything directly justifying this, but it seems obvious. llvm-svn: 108521
* Fix PR7617 by not entering ParseFunctionDefinition whenChris Lattner2010-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-6/+6
| | | | | | | | | | | | | | 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
* Implement C++ DR481, which clarifies that the scope of templateDouglas Gregor2010-07-011-45/+35
| | | | | | | | | | | | | | | | | parameters starts at the end of the template-parameter rather than at the point where the template parameter name is encounted. For example, given: typedef unsigned char T; template<typename T = T> struct X0 { }; The "T" in the default argument refers to the typedef of "unsigned char", rather than referring to the newly-introduced template type parameter 'T'. Addresses <rdar://problem/8122812>. llvm-svn: 107354
* When we see a 'template' disambiguator that marks the next identifierDouglas Gregor2010-06-161-9/+8
| | | | | | | | | | | (or operator-function-id) as a template, but the context is actually non-dependent or the current instantiation, allow us to use knowledge of what kind of template it is, e.g., type template vs. function template, for further syntactic disambiguation. This allows us to parse properly in the presence of stray "template" keywords, which is necessary in C++0x and it's good recovery in C++98/03. llvm-svn: 106167
* Fix the recently-added warning about 'typename' and 'template'Douglas Gregor2010-06-161-3/+3
| | | | | | | | | 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
* Properly disambiguate between an elaborated-type-specifier and aDouglas Gregor2010-06-041-2/+31
| | | | | | type-parameter within a template parameter list. Found by inspection. llvm-svn: 105462
* Improve recovery when we see a dependent template name that is missingDouglas Gregor2010-05-211-1/+6
| | | | | | | | | | | | | | | the required "template" keyword, using the same heuristics we do for dependent template names in member access expressions, e.g., test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template' keyword to treat 'getAs' as a dependent template name T::getAs<U>(); ^ template Fixes PR5404. llvm-svn: 104409
* Improve parser recovery when we encounter a dependent template nameDouglas Gregor2010-05-211-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-1/+1
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-1/+1
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-1/+1
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
OpenPOWER on IntegriCloud