diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-05-19 23:10:31 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-05-19 23:10:31 +0000 |
| commit | ad3150cd380bbc69cc15e449052776605e15c9b6 (patch) | |
| tree | 9887ff9e984c3dffe7b467fedbce5b715bc47666 /clang/lib/Sema/SemaTemplateInstantiateExpr.cpp | |
| parent | 0df91121ba168ef283abdf2faa9b759343c28152 (diff) | |
| download | bcm5719-llvm-ad3150cd380bbc69cc15e449052776605e15c9b6.tar.gz bcm5719-llvm-ad3150cd380bbc69cc15e449052776605e15c9b6.zip | |
Template instantiation for __builtin_va_arg.
llvm-svn: 72144
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateExpr.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp b/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp index 92a152c2e3f..56126d45046 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -59,6 +59,7 @@ namespace { OwningExprResult VisitTypesCompatibleExpr(TypesCompatibleExpr *E); OwningExprResult VisitShuffleVectorExpr(ShuffleVectorExpr *E); OwningExprResult VisitChooseExpr(ChooseExpr *E); + OwningExprResult VisitVAArgExpr(VAArgExpr *E); OwningExprResult VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); OwningExprResult VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *E); OwningExprResult VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E); @@ -162,12 +163,17 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) { *Arg.getAsIntegral(), T, E->getSourceRange().getBegin())); - } else if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) + } else if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { NewD = SemaRef.CurrentInstantiationScope->getInstantiationOf(Parm); - else if (isa<FunctionDecl>(D) || isa<OverloadedFunctionDecl>(D)) + } else if (VarDecl *Var = dyn_cast<VarDecl>(D)) { + if (Var->hasLocalStorage()) + NewD = SemaRef.CurrentInstantiationScope->getInstantiationOf(Var); + else + assert(false && "Cannot instantiation non-local variable declarations"); + } else if (isa<FunctionDecl>(D) || isa<OverloadedFunctionDecl>(D)) { // FIXME: Instantiate decl! NewD = cast<ValueDecl>(D); - else + } else assert(false && "Unhandled declaratrion reference kind"); if (!NewD) @@ -540,6 +546,24 @@ TemplateExprInstantiator::VisitChooseExpr(ChooseExpr *E) { E->getRParenLoc()); } +Sema::OwningExprResult TemplateExprInstantiator::VisitVAArgExpr(VAArgExpr *E) { + OwningExprResult SubExpr = Visit(E->getSubExpr()); + if (SubExpr.isInvalid()) + return SemaRef.ExprError(); + + SourceLocation FakeTypeLoc + = SemaRef.PP.getLocForEndOfToken(E->getSubExpr()->getSourceRange() + .getEnd()); + QualType T = SemaRef.InstantiateType(E->getType(), TemplateArgs, + /*FIXME:*/FakeTypeLoc, + DeclarationName()); + if (T.isNull()) + return SemaRef.ExprError(); + + return SemaRef.ActOnVAArg(E->getBuiltinLoc(), move(SubExpr), + T.getAsOpaquePtr(), E->getRParenLoc()); +} + Sema::OwningExprResult TemplateExprInstantiator::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { bool isSizeOf = E->isSizeOf(); |

