summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the template-instantiation logic for expressions into aDouglas Gregor2009-08-111-1377/+0
| | | | | | | generic tree transformation (also used for recanonicalization) and a small amount of template-instantiation-specific logic. llvm-svn: 78645
* Take 2 on AltiVec-style vector initializers. Nate Begeman2009-08-101-1/+15
| | | | | | | | | | | | Fixes PR4704 problems Addresses Eli's patch feedback re: ugly cast code Updates all postfix operators to remove ParenListExprs. While this is awful, no better solution (say, in the parser) is obvious to me. Better solutions welcome. llvm-svn: 78621
* Revert r78535, it is causing a number of failures to build projects.Daniel Dunbar2009-08-101-15/+1
| | | | | | | | | | | | | | | | | | | | | | | | --- Reverse-merging r78535 into '.': D test/Sema/altivec-init.c U include/clang/Basic/DiagnosticSemaKinds.td U include/clang/AST/Expr.h U include/clang/AST/StmtNodes.def U include/clang/Parse/Parser.h U include/clang/Parse/Action.h U tools/clang-cc/clang-cc.cpp U lib/Frontend/PrintParserCallbacks.cpp U lib/CodeGen/CGExprScalar.cpp U lib/Sema/SemaInit.cpp U lib/Sema/Sema.h U lib/Sema/SemaExpr.cpp U lib/Sema/SemaTemplateInstantiateExpr.cpp U lib/AST/StmtProfile.cpp U lib/AST/Expr.cpp U lib/AST/StmtPrinter.cpp U lib/Parse/ParseExpr.cpp U lib/Parse/ParseExprCXX.cpp llvm-svn: 78551
* AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);Nate Begeman2009-08-091-1/+15
| | | | | | | | In addition to being defined by the AltiVec PIM, this is also the vector initializer syntax used by OpenCL, so that vector literals are compatible with macro arguments. llvm-svn: 78535
* Get rid of Stmt::Clone now that we can reference count statements instead.Anders Carlsson2009-08-081-1/+1
| | | | llvm-svn: 78452
* Introduce reference counting for statements and expressions, using itDouglas Gregor2009-08-081-15/+16
| | | | | | | to allow sharing of nodes. Simplifies some aspects of template instantiation, and fixes both PR3444 and <rdar://problem/6757457>. llvm-svn: 78450
* Support nested-name-specifiers for C++ member access expressions, e.g.,Douglas Gregor2009-08-061-4/+8
| | | | | | | | this->Base::foo from James Porter! llvm-svn: 78278
* Patch to improve ir-gen for constructors with default argumentFariborz Jahanian2009-08-051-5/+5
| | | | | | expressions and a test case. llvm-svn: 78213
* Fix assertion crash. I don't have a testcase, but the fix is pretty Eli Friedman2009-08-031-1/+1
| | | | | | obviously correct. llvm-svn: 77969
* Add a CastKind enum to CastExpr. Right now it's not used for much but it ↵Anders Carlsson2009-07-311-0/+1
| | | | | | will be :) llvm-svn: 77650
* [llvm up]Douglas Gregor2009-07-291-1/+2
| | | | | | | | | A template name can refer to a set of overloaded function templates. Model this in TemplateName, which can now refer to an OverloadedFunctionDecl that contains function templates. This removes an unspeakable hack in Sema::isTemplateName. llvm-svn: 77488
* Allow front-end 'isa' access on object's of type 'id'.Steve Naroff2009-07-241-0/+6
| | | | | | | | Enhance test case to cover 'isa' access on interface types (clang produces an error, GCC produces a warning). Still need back-end CodeGen for ObjCIsaExpr. llvm-svn: 76979
* Store the isAddressOfOperand in the UnresolvedDeclRefExpr, so that we can ↵Anders Carlsson2009-07-091-1/+1
| | | | | | pass it when instantiating the expr. Fixes another member pointer bug. llvm-svn: 75075
* Cope with explicitly-specified function template arguments when thereDouglas Gregor2009-07-011-1/+10
| | | | | | | are fewer template arguments than there are template parameters for that function. llvm-svn: 74578
* Preliminary parsing and ASTs for template-ids that refer to functionDouglas Gregor2009-06-301-0/+28
| | | | | | | templates, such as make<int&>. These template-ids are only barely functional for function calls; much more to come. llvm-svn: 74563
* Refactor ActOnDeclarationNameExpr into a "parsing action" part and aDouglas Gregor2009-06-301-10/+7
| | | | | | | | | | | "semantic analysis" part. Use the "semantic analysis" part when performing template instantiation on a DeclRefExpr, rather than an ad hoc list of rules to construct DeclRefExprs from the instantiation. A test case for this change will come in with a large commit, which illustrates what I was actually trying to work on. llvm-svn: 74528
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-2/+1
| | | | | | | Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. llvm-svn: 74506
* Fix PR4448.Anders Carlsson2009-06-261-0/+8
| | | | llvm-svn: 74257
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | templates. For example, this now type-checks (but does not instantiate the body of deref<int>): template<typename T> T& deref(T* t) { return *t; } void test(int *ip) { int &ir = deref(ip); } Specific changes/additions: * Template argument deduction from a call to a function template. * Instantiation of a function template specializations (just the declarations) from the template arguments deduced from a call. * FunctionTemplateDecls are stored directly in declaration contexts and found via name lookup (all forms), rather than finding the FunctionDecl and then realizing it is a template. This is responsible for most of the churn, since some of the core declaration matching and lookup code assumes that all functions are FunctionDecls. llvm-svn: 74213
* Rework the way we track which declarations are "used" duringDouglas Gregor2009-06-221-3/+17
| | | | | | | | | | | | | | | | | | | | | compilation, and (hopefully) introduce RAII objects for changing the "potentially evaluated" state at all of the necessary places within Sema and Parser. Other changes: - Set the unevaluated/potentially-evaluated context appropriately during template instantiation. - We now recognize three different states while parsing or instantiating expressions: unevaluated, potentially evaluated, and potentially potentially evaluated (for C++'s typeid). - When we're in a potentially potentially-evaluated context, queue up MarkDeclarationReferenced calls in a stack. For C++ typeid expressions that are potentially evaluated, we will play back these MarkDeclarationReferenced calls when we exit the corresponding potentially potentially-evaluated context. - Non-type template arguments are now parsed as constant expressions, so they are not potentially-evaluated. llvm-svn: 73899
* Handle temporaries in default arguments.Anders Carlsson2009-06-161-1/+4
| | | | llvm-svn: 73462
* Diagnose the incorrect use of non-type template arguments for classDouglas Gregor2009-06-121-0/+8
| | | | | | template partial specializations. llvm-svn: 73254
* Instantiation support for more Obj-C expressions, string literals, @selector ↵Anders Carlsson2009-06-071-7/+4
| | | | | | and @protocol expressions. llvm-svn: 73036
* Template instantiation support for Obj-C @encode expressions.Anders Carlsson2009-06-071-3/+11
| | | | llvm-svn: 73034
* Several improvements to template argument deduction:Douglas Gregor2009-06-051-1/+2
| | | | | | | | | | | | | | - Once we have deduced template arguments for a class template partial specialization, we use exactly those template arguments for instantiating the definition of the class template partial specialization. - Added template argument deduction for non-type template parameters. - Added template argument deduction for dependently-sized array types. With these changes, we can now implement, e.g., the remove_reference type trait. Also, Daniel's Ackermann template metaprogram now compiles properly. llvm-svn: 72909
* Remove VarDecl from CXXConstructExpr.Anders Carlsson2009-05-301-9/+1
| | | | llvm-svn: 72633
* Bind temporaries correctly when instantiating expressions.Anders Carlsson2009-05-301-1/+1
| | | | llvm-svn: 72632
* Add a CXXBindTemporaryExpr.Anders Carlsson2009-05-301-0/+10
| | | | llvm-svn: 72627
* Reduce the amount of stack space we use in SmallVectors duringDouglas Gregor2009-05-291-2/+2
| | | | | | | template instantiation. This helps reduce our stack footprint when performing deep template instantiations. llvm-svn: 72582
* Simplify, and improve the performance of, template instantiation forDouglas Gregor2009-05-271-2/+1
| | | | | | | | | | | declaration references. The key realization is that dependent Decls, which actually require instantiation, can only refer to the current instantiation or members thereof. And, since the current context during instantiation contains all of those members of the current instantiation, we can simply find the real instantiate that matches up with the "current instantiation" template. llvm-svn: 72486
* Improve name lookup for and template instantiation of declarationDouglas Gregor2009-05-271-18/+10
| | | | | | | | | | | | | | | | | | | | | | | references. There are several smallish fixes here: - Make sure we look through template parameter scope when determining whether we're parsing a nested class (or nested class *template*). This makes sure that we delay parsing the bodies of inline member functions until after we're out of the outermost class (template) scope. - Since the bodies of member functions are always parsed "out-of-line", even when they were declared in-line, teach unqualified name lookup to look into the (semantic) parents. - Use the new InstantiateDeclRef to handle the instantiation of a reference to a declaration (in DeclRefExpr), which drastically simplifies template instantiation for DeclRefExprs. - When we're instantiating a ParmVarDecl, it must be in the current instantiation scope, so only look there. Also, remove the #if 0's and FIXME's from the dynarray example, which now compiles and executes thanks to Anders and Eli. llvm-svn: 72481
* Initial stab at a generalized operation for determining theDouglas Gregor2009-05-271-0/+1
| | | | | | | | | | | | instantiation of a declaration from the template version (or version that lives in a template) and a given set of template arguments. This needs much, much more testing, but it suffices for simple examples like typedef T* iterator; iterator begin(); llvm-svn: 72461
* Template instantiation for "typeof" for both types and expressions.Douglas Gregor2009-05-261-1/+7
| | | | llvm-svn: 72440
* Template instantiation for qualified declaration referenceDouglas Gregor2009-05-221-70/+112
| | | | | | | | | | | | | | | | | | expressions. We are now missing template instantiation logic for only three classes of expressions: - Blocks-related expressions (BlockExpr, BlockDeclRefExpr) - C++ default argument expressions - Objective-C expressions Additionally, our handling of DeclRefExpr is still quite poor, since it cannot handle references to many kinds of declarations. As part of this change, converted the TemplateExprInstantiator to use iteration through all of the expressions via clang/AST/StmtNodes.def, ensuring that we don't forget to add template instantiation logic for any new expression node kinds. llvm-svn: 72303
* Template instantiation for the GNU address-of-label extension.Douglas Gregor2009-05-221-1/+8
| | | | llvm-svn: 72301
* Template instantiation for ExtVectorElementExpr.Douglas Gregor2009-05-221-1/+18
| | | | llvm-svn: 72299
* Add a few tests to ensure that member functions of class templates canDouglas Gregor2009-05-221-1/+6
| | | | | | | call other member functions of class templates, including after template instantiation. No functionality change. llvm-svn: 72282
* Representation of and template instantiation for memberDouglas Gregor2009-05-221-1/+40
| | | | | | | | | | | | expressions. This change introduces another AST node, CXXUnresolvedMemberExpr, that captures member references (x->m, x.m) when the base of the expression (the "x") is type-dependent, and we therefore cannot resolve the member reference yet. Note that our parsing of member references for C++ is still quite poor, e.g., we don't handle x->Base::m or x->operator int. llvm-svn: 72281
* Template instantiation for C99 compound literalsDouglas Gregor2009-05-211-1/+21
| | | | llvm-svn: 72236
* Template instantiation for GNU array-range designators.Douglas Gregor2009-05-211-1/+16
| | | | llvm-svn: 72234
* Template instantiation for C99 designated initializers, because weDouglas Gregor2009-05-211-2/+59
| | | | | | | | can. Also, delay semantic analysis of initialization for value-dependent as well as type-dependent expressions, since we can't always properly type-check a value-dependent expression. llvm-svn: 72233
* Template instantiation for initializer listsDouglas Gregor2009-05-211-1/+15
| | | | llvm-svn: 72229
* Template instantiation for unary type traits, e.g., __is_podDouglas Gregor2009-05-211-1/+18
| | | | llvm-svn: 72220
* Template instantiation for C++ "typeid" expressions.Douglas Gregor2009-05-211-1/+33
| | | | llvm-svn: 72218
* Template instantiation for C++ throw expressionsDouglas Gregor2009-05-211-1/+13
| | | | llvm-svn: 72217
* Template instantiation for C++ delete expressionDouglas Gregor2009-05-211-1/+13
| | | | llvm-svn: 72216
* Merge the ASTVector and ASTOwningVector templates, since they offeredDouglas Gregor2009-05-211-11/+4
| | | | | | | | redundant functionality. The result (ASTOwningVector) lives in clang/Parse/Ownership.h and is used by both the parser and semantic analysis. No intended functionality change. llvm-svn: 72214
* Template instantiation for C++ "new" expressions.Douglas Gregor2009-05-211-1/+56
| | | | llvm-svn: 72199
* Fix template instantiation for compound statements so that it properlyDouglas Gregor2009-05-201-2/+2
| | | | | | | passes the "isStmtExpr" flag, to suppress warnings about unused expressions. llvm-svn: 72190
* Introduce a new kind of RAII class, ASTOwningVector, which is anDouglas Gregor2009-05-201-72/+36
| | | | | | | | llvm::SmallVector that owns all of the AST nodes inside of it. This RAII class is used to ensure proper destruction of AST nodes when template instantiation fails. llvm-svn: 72186
OpenPOWER on IntegriCloud