aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-15 01:34:56 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-15 01:34:56 +0000
commitbebbe0d9b7568ce43a464286bee49429489ef483 (patch)
treef46d0fb0c81e0d5b47522d8bc162398b3e9ee7d4 /lib/AST/Type.cpp
parent8cc246c9a68c783a5b90d2e8b8927521cb3a49b7 (diff)
Variadic templates: extend the Expr class with a bit that specifies
whether the expression contains an unexpanded parameter pack, in the same vein as the changes to the Type hierarchy. Compute this bit within all of the Expr subclasses. This change required a bunch of reshuffling of dependency calculations, mainly to consolidate them inside the constructors and to fuse multiple loops that iterate over arguments to determine type dependence, value dependence, and (now) containment of unexpanded parameter packs. Again, testing is painfully sparse, because all of the diagnostics will change and it is more important to test the to-be-written visitor that collects unexpanded parameter packs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp45
1 files changed, 3 insertions, 42 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 25aa5e0ea1..0991e5a709 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1220,45 +1220,6 @@ bool EnumType::classof(const TagType *TT) {
return isa<EnumDecl>(TT->getDecl());
}
-static bool isDependent(const TemplateArgument &Arg) {
- switch (Arg.getKind()) {
- case TemplateArgument::Null:
- assert(false && "Should not have a NULL template argument");
- return false;
-
- case TemplateArgument::Type:
- return Arg.getAsType()->isDependentType();
-
- case TemplateArgument::Template:
- return Arg.getAsTemplate().isDependent();
-
- case TemplateArgument::Declaration:
- if (DeclContext *DC = dyn_cast<DeclContext>(Arg.getAsDecl()))
- return DC->isDependentContext();
- return Arg.getAsDecl()->getDeclContext()->isDependentContext();
-
- case TemplateArgument::Integral:
- // Never dependent
- return false;
-
- case TemplateArgument::Expression:
- return (Arg.getAsExpr()->isTypeDependent() ||
- Arg.getAsExpr()->isValueDependent());
-
- case TemplateArgument::Pack:
- for (TemplateArgument::pack_iterator P = Arg.pack_begin(),
- PEnd = Arg.pack_end();
- P != PEnd; ++P) {
- if (isDependent(*P))
- return true;
- }
-
- return false;
- }
-
- return false;
-}
-
bool TemplateSpecializationType::
anyDependentTemplateArguments(const TemplateArgumentListInfo &Args) {
return anyDependentTemplateArguments(Args.getArgumentArray(), Args.size());
@@ -1267,7 +1228,7 @@ anyDependentTemplateArguments(const TemplateArgumentListInfo &Args) {
bool TemplateSpecializationType::
anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned N) {
for (unsigned i = 0; i != N; ++i)
- if (isDependent(Args[i].getArgument()))
+ if (Args[i].getArgument().isDependent())
return true;
return false;
}
@@ -1275,7 +1236,7 @@ anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned N) {
bool TemplateSpecializationType::
anyDependentTemplateArguments(const TemplateArgument *Args, unsigned N) {
for (unsigned i = 0; i != N; ++i)
- if (isDependent(Args[i]))
+ if (Args[i].isDependent())
return true;
return false;
}
@@ -1298,7 +1259,7 @@ TemplateSpecializationType(TemplateName T,
= reinterpret_cast<TemplateArgument *>(this + 1);
for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
// Update dependent and variably-modified bits.
- if (isDependent(Args[Arg]))
+ if (Args[Arg].isDependent())
setDependent();
if (Args[Arg].getKind() == TemplateArgument::Type &&
Args[Arg].getAsType()->isVariablyModifiedType())