forked from OSchip/llvm-project
Refactor the Get* functions to be more consistant among themselves.
llvm-svn: 178613
This commit is contained in:
parent
b8c8836594
commit
17f13ecc5b
|
@ -838,8 +838,8 @@ class TemplateDiff {
|
||||||
if (TemplateTypeParmDecl *DefaultTTPD =
|
if (TemplateTypeParmDecl *DefaultTTPD =
|
||||||
dyn_cast<TemplateTypeParmDecl>(ParamND)) {
|
dyn_cast<TemplateTypeParmDecl>(ParamND)) {
|
||||||
QualType FromType, ToType;
|
QualType FromType, ToType;
|
||||||
GetType(FromIter, DefaultTTPD, FromType);
|
FromType = GetType(FromIter, DefaultTTPD);
|
||||||
GetType(ToIter, DefaultTTPD, ToType);
|
ToType = GetType(ToIter, DefaultTTPD);
|
||||||
Tree.SetNode(FromType, ToType);
|
Tree.SetNode(FromType, ToType);
|
||||||
Tree.SetDefault(FromIter.isEnd() && !FromType.isNull(),
|
Tree.SetDefault(FromIter.isEnd() && !FromType.isNull(),
|
||||||
ToIter.isEnd() && !ToType.isNull());
|
ToIter.isEnd() && !ToType.isNull());
|
||||||
|
@ -898,14 +898,14 @@ class TemplateDiff {
|
||||||
else if (HasFromValueDecl)
|
else if (HasFromValueDecl)
|
||||||
FromValueDecl = FromIter->getAsDecl();
|
FromValueDecl = FromIter->getAsDecl();
|
||||||
else
|
else
|
||||||
GetExpr(FromIter, DefaultNTTPD, FromExpr);
|
FromExpr = GetExpr(FromIter, DefaultNTTPD);
|
||||||
|
|
||||||
if (HasToInt)
|
if (HasToInt)
|
||||||
ToInt = ToIter->getAsIntegral();
|
ToInt = ToIter->getAsIntegral();
|
||||||
else if (HasToValueDecl)
|
else if (HasToValueDecl)
|
||||||
ToValueDecl = ToIter->getAsDecl();
|
ToValueDecl = ToIter->getAsDecl();
|
||||||
else
|
else
|
||||||
GetExpr(ToIter, DefaultNTTPD, ToExpr);
|
ToExpr = GetExpr(ToIter, DefaultNTTPD);
|
||||||
|
|
||||||
if (!HasFromInt && !HasToInt && !HasFromValueDecl && !HasToValueDecl) {
|
if (!HasFromInt && !HasToInt && !HasFromValueDecl && !HasToValueDecl) {
|
||||||
Tree.SetNode(FromExpr, ToExpr);
|
Tree.SetNode(FromExpr, ToExpr);
|
||||||
|
@ -956,8 +956,8 @@ class TemplateDiff {
|
||||||
if (TemplateTemplateParmDecl *DefaultTTPD =
|
if (TemplateTemplateParmDecl *DefaultTTPD =
|
||||||
dyn_cast<TemplateTemplateParmDecl>(ParamND)) {
|
dyn_cast<TemplateTemplateParmDecl>(ParamND)) {
|
||||||
TemplateDecl *FromDecl, *ToDecl;
|
TemplateDecl *FromDecl, *ToDecl;
|
||||||
GetTemplateDecl(FromIter, DefaultTTPD, FromDecl);
|
FromDecl = GetTemplateDecl(FromIter, DefaultTTPD);
|
||||||
GetTemplateDecl(ToIter, DefaultTTPD, ToDecl);
|
ToDecl = GetTemplateDecl(ToIter, DefaultTTPD);
|
||||||
Tree.SetNode(FromDecl, ToDecl);
|
Tree.SetNode(FromDecl, ToDecl);
|
||||||
Tree.SetSame(
|
Tree.SetSame(
|
||||||
FromDecl && ToDecl &&
|
FromDecl && ToDecl &&
|
||||||
|
@ -1032,22 +1032,21 @@ class TemplateDiff {
|
||||||
|
|
||||||
/// GetType - Retrieves the template type arguments, including default
|
/// GetType - Retrieves the template type arguments, including default
|
||||||
/// arguments.
|
/// arguments.
|
||||||
void GetType(const TSTiterator &Iter, TemplateTypeParmDecl *DefaultTTPD,
|
QualType GetType(const TSTiterator &Iter, TemplateTypeParmDecl *DefaultTTPD) {
|
||||||
QualType &ArgType) {
|
|
||||||
ArgType = QualType();
|
|
||||||
bool isVariadic = DefaultTTPD->isParameterPack();
|
bool isVariadic = DefaultTTPD->isParameterPack();
|
||||||
|
|
||||||
if (!Iter.isEnd())
|
if (!Iter.isEnd())
|
||||||
ArgType = Iter->getAsType();
|
return Iter->getAsType();
|
||||||
else if (!isVariadic)
|
if (!isVariadic)
|
||||||
ArgType = DefaultTTPD->getDefaultArgument();
|
return DefaultTTPD->getDefaultArgument();
|
||||||
|
|
||||||
|
return QualType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetExpr - Retrieves the template expression argument, including default
|
/// GetExpr - Retrieves the template expression argument, including default
|
||||||
/// arguments.
|
/// arguments.
|
||||||
void GetExpr(const TSTiterator &Iter, NonTypeTemplateParmDecl *DefaultNTTPD,
|
Expr *GetExpr(const TSTiterator &Iter, NonTypeTemplateParmDecl *DefaultNTTPD) {
|
||||||
Expr *&ArgExpr) {
|
Expr *ArgExpr = 0;
|
||||||
ArgExpr = 0;
|
|
||||||
bool isVariadic = DefaultNTTPD->isParameterPack();
|
bool isVariadic = DefaultNTTPD->isParameterPack();
|
||||||
|
|
||||||
if (!Iter.isEnd())
|
if (!Iter.isEnd())
|
||||||
|
@ -1059,6 +1058,8 @@ class TemplateDiff {
|
||||||
while (SubstNonTypeTemplateParmExpr *SNTTPE =
|
while (SubstNonTypeTemplateParmExpr *SNTTPE =
|
||||||
dyn_cast<SubstNonTypeTemplateParmExpr>(ArgExpr))
|
dyn_cast<SubstNonTypeTemplateParmExpr>(ArgExpr))
|
||||||
ArgExpr = SNTTPE->getReplacement();
|
ArgExpr = SNTTPE->getReplacement();
|
||||||
|
|
||||||
|
return ArgExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetInt - Retrieves the template integer argument, including evaluating
|
/// GetInt - Retrieves the template integer argument, including evaluating
|
||||||
|
@ -1099,10 +1100,8 @@ class TemplateDiff {
|
||||||
|
|
||||||
/// GetTemplateDecl - Retrieves the template template arguments, including
|
/// GetTemplateDecl - Retrieves the template template arguments, including
|
||||||
/// default arguments.
|
/// default arguments.
|
||||||
void GetTemplateDecl(const TSTiterator &Iter,
|
TemplateDecl *GetTemplateDecl(const TSTiterator &Iter,
|
||||||
TemplateTemplateParmDecl *DefaultTTPD,
|
TemplateTemplateParmDecl *DefaultTTPD) {
|
||||||
TemplateDecl *&ArgDecl) {
|
|
||||||
ArgDecl = 0;
|
|
||||||
bool isVariadic = DefaultTTPD->isParameterPack();
|
bool isVariadic = DefaultTTPD->isParameterPack();
|
||||||
|
|
||||||
TemplateArgument TA = DefaultTTPD->getDefaultArgument().getArgument();
|
TemplateArgument TA = DefaultTTPD->getDefaultArgument().getArgument();
|
||||||
|
@ -1111,9 +1110,11 @@ class TemplateDiff {
|
||||||
DefaultTD = TA.getAsTemplate().getAsTemplateDecl();
|
DefaultTD = TA.getAsTemplate().getAsTemplateDecl();
|
||||||
|
|
||||||
if (!Iter.isEnd())
|
if (!Iter.isEnd())
|
||||||
ArgDecl = Iter->getAsTemplate().getAsTemplateDecl();
|
return Iter->getAsTemplate().getAsTemplateDecl();
|
||||||
else if (!isVariadic)
|
if (!isVariadic)
|
||||||
ArgDecl = DefaultTD;
|
return DefaultTD;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// IsSameConvertedInt - Returns true if both integers are equal when
|
/// IsSameConvertedInt - Returns true if both integers are equal when
|
||||||
|
|
Loading…
Reference in New Issue