diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-17 01:46:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-17 01:46:05 +0000 |
commit | 7ee4307bd4450022c3c8777f43a40cc4f0ccc009 (patch) | |
tree | 15419c16f2805145912b9210e17268c957869de3 /clang/lib/Sema/SemaTemplate.cpp | |
parent | 457d7caac82260adc5754d62f7133b178c7766be (diff) | |
download | bcm5719-llvm-7ee4307bd4450022c3c8777f43a40cc4f0ccc009.tar.gz bcm5719-llvm-7ee4307bd4450022c3c8777f43a40cc4f0ccc009.zip |
Refactor constant evaluation of typeid(T) to track a symbolic type_info
object rather than tracking the originating expression.
This is groundwork for supporting polymorphic typeid expressions. (Note
that this somewhat regresses our support for DR1968, but it turns out
that that never actually worked anyway, at least in non-trivial cases.)
llvm-svn: 360974
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index b9d3ff8666f..239b4ae7957 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -6424,8 +6424,11 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // -- a string literal // -- the result of a typeid expression, or // -- a predefined __func__ variable - if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) { - if (isa<CXXUuidofExpr>(E)) { + APValue::LValueBase Base = Value.getLValueBase(); + auto *VD = const_cast<ValueDecl *>(Base.dyn_cast<const ValueDecl *>()); + if (Base && !VD) { + auto *E = Base.dyn_cast<const Expr *>(); + if (E && isa<CXXUuidofExpr>(E)) { Converted = TemplateArgument(ArgResult.get()->IgnoreImpCasts()); break; } @@ -6433,8 +6436,6 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, << Arg->getSourceRange(); return ExprError(); } - auto *VD = const_cast<ValueDecl *>( - Value.getLValueBase().dyn_cast<const ValueDecl *>()); // -- a subobject if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && VD && VD->getType()->isArrayType() && |