summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateVariadic.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-12 17:07:58 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-12 17:07:58 +0000
commit822d0301189425454dac52cfc473072c835700cd (patch)
tree499254803771ff8c55dc4670a9503b0c0343fc34 /clang/lib/Sema/SemaTemplateVariadic.cpp
parent7ecc2fc4ca91b4b0cd30fe74e0250a192d52b17c (diff)
downloadbcm5719-llvm-822d0301189425454dac52cfc473072c835700cd.tar.gz
bcm5719-llvm-822d0301189425454dac52cfc473072c835700cd.zip
Teach TreeTransform how to transform a pack expansion type into
another pack expansion type. This can happen when rebuilding types in the current instantiation. Fixes <rdar://problem/8848837> (Clang crashing on libc++ <functional>). llvm-svn: 123316
Diffstat (limited to 'clang/lib/Sema/SemaTemplateVariadic.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateVariadic.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 63a8394d67a..473dcb7d1fa 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -377,18 +377,13 @@ TypeResult Sema::ActOnPackExpansion(ParsedType Type,
TypeSourceInfo *Sema::CheckPackExpansion(TypeSourceInfo *Pattern,
SourceLocation EllipsisLoc) {
- // C++0x [temp.variadic]p5:
- // The pattern of a pack expansion shall name one or more
- // parameter packs that are not expanded by a nested pack
- // expansion.
- if (!Pattern->getType()->containsUnexpandedParameterPack()) {
- Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
- << Pattern->getTypeLoc().getSourceRange();
+ // Create the pack expansion type and source-location information.
+ QualType Result = CheckPackExpansion(Pattern->getType(),
+ Pattern->getTypeLoc().getSourceRange(),
+ EllipsisLoc);
+ if (Result.isNull())
return 0;
- }
- // Create the pack expansion type and source-location information.
- QualType Result = Context.getPackExpansionType(Pattern->getType());
TypeSourceInfo *TSResult = Context.CreateTypeSourceInfo(Result);
PackExpansionTypeLoc TL = cast<PackExpansionTypeLoc>(TSResult->getTypeLoc());
TL.setEllipsisLoc(EllipsisLoc);
@@ -400,6 +395,22 @@ TypeSourceInfo *Sema::CheckPackExpansion(TypeSourceInfo *Pattern,
return TSResult;
}
+QualType Sema::CheckPackExpansion(QualType Pattern,
+ SourceRange PatternRange,
+ SourceLocation EllipsisLoc) {
+ // C++0x [temp.variadic]p5:
+ // The pattern of a pack expansion shall name one or more
+ // parameter packs that are not expanded by a nested pack
+ // expansion.
+ if (!Pattern->containsUnexpandedParameterPack()) {
+ Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
+ << PatternRange;
+ return QualType();
+ }
+
+ return Context.getPackExpansionType(Pattern);
+}
+
ExprResult Sema::ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) {
if (!Pattern)
return ExprError();
OpenPOWER on IntegriCloud