aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/DeclTemplate.cpp17
-rw-r--r--clang/lib/AST/Expr.cpp27
2 files changed, 38 insertions, 6 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index c0be986..2f7ae6d 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1670,20 +1670,25 @@ clang::getReplacedTemplateParameter(Decl *D, unsigned Index) {
auto P = CTSD->getSpecializedTemplateOrPartial();
TemplateParameterList *TPL;
if (const auto *CTPSD =
- dyn_cast<ClassTemplatePartialSpecializationDecl *>(P))
+ dyn_cast<ClassTemplatePartialSpecializationDecl *>(P)) {
TPL = CTPSD->getTemplateParameters();
- else
- TPL = cast<ClassTemplateDecl *>(P)->getTemplateParameters();
+ // FIXME: Obtain Args deduced for the partial specialization.
+ return {TPL->getParam(Index), {}};
+ }
+ TPL = cast<ClassTemplateDecl *>(P)->getTemplateParameters();
return {TPL->getParam(Index), CTSD->getTemplateArgs()[Index]};
}
case Decl::Kind::VarTemplateSpecialization: {
const auto *VTSD = cast<VarTemplateSpecializationDecl>(D);
auto P = VTSD->getSpecializedTemplateOrPartial();
TemplateParameterList *TPL;
- if (const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl *>(P))
+ if (const auto *VTPSD =
+ dyn_cast<VarTemplatePartialSpecializationDecl *>(P)) {
TPL = VTPSD->getTemplateParameters();
- else
- TPL = cast<VarTemplateDecl *>(P)->getTemplateParameters();
+ // FIXME: Obtain Args deduced for the partial specialization.
+ return {TPL->getParam(Index), {}};
+ }
+ TPL = cast<VarTemplateDecl *>(P)->getTemplateParameters();
return {TPL->getParam(Index), VTSD->getTemplateArgs()[Index]};
}
case Decl::Kind::ClassTemplatePartialSpecialization:
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f899b3c..597cbd8 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -5290,6 +5290,33 @@ QualType ArraySectionExpr::getBaseOriginalType(const Expr *Base) {
return OriginalTy;
}
+QualType ArraySectionExpr::getElementType() const {
+ QualType BaseTy = getBase()->IgnoreParenImpCasts()->getType();
+ // We only have to look into the array section exprs, else we will get the
+ // type of the base, which should already be valid.
+ if (auto *ASE = dyn_cast<ArraySectionExpr>(getBase()->IgnoreParenImpCasts()))
+ BaseTy = ASE->getElementType();
+
+ if (BaseTy->isAnyPointerType())
+ return BaseTy->getPointeeType();
+ if (BaseTy->isArrayType())
+ return BaseTy->castAsArrayTypeUnsafe()->getElementType();
+
+ // If this isn't a pointer or array, the base is a dependent expression, so
+ // just return the BaseTy anyway.
+ assert(BaseTy->isInstantiationDependentType());
+ return BaseTy;
+}
+
+QualType ArraySectionExpr::getBaseType() const {
+ // We only have to look into the array section exprs, else we will get the
+ // type of the base, which should already be valid.
+ if (auto *ASE = dyn_cast<ArraySectionExpr>(getBase()->IgnoreParenImpCasts()))
+ return ASE->getElementType();
+
+ return getBase()->IgnoreParenImpCasts()->getType();
+}
+
RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation BeginLoc,
SourceLocation EndLoc, ArrayRef<Expr *> SubExprs)
: Expr(RecoveryExprClass, T.getNonReferenceType(),