C++: Print print nontype template params

This commit is contained in:
Matthew Gretton-Dann
2019-10-23 16:29:32 +01:00
parent f1c3ce04d1
commit 809d97de02
3 changed files with 14 additions and 5 deletions

View File

@@ -35,6 +35,14 @@ private string getParameterTypeString(Type parameterType) {
else result = parameterType.(DumpType).getTypeIdentityString() else result = parameterType.(DumpType).getTypeIdentityString()
} }
private string getTemplateArgumentString(Declaration d, int i) {
if exists(d.getTemplateArgumentValue(i))
then
result = d.getTemplateArgument(i).(DumpType).getTypeIdentityString() + " " + d.getTemplateArgumentValue(i)
else
result = d.getTemplateArgument(i).(DumpType).getTypeIdentityString()
}
/** /**
* A `Declaration` extended to add methods for generating strings useful only for dumps and debugging. * A `Declaration` extended to add methods for generating strings useful only for dumps and debugging.
*/ */
@@ -56,7 +64,7 @@ abstract private class DumpDeclaration extends Declaration {
strictconcat(int i | strictconcat(int i |
exists(this.getTemplateArgument(i)) exists(this.getTemplateArgument(i))
| |
this.getTemplateArgument(i).(DumpType).getTypeIdentityString(), ", " order by i getTemplateArgumentString(this, i), ", " order by i
) + ">" ) + ">"
else result = "" else result = ""
} }

View File

@@ -67,7 +67,7 @@ bad_asts.cpp:
# 5| params: # 5| params:
#-----| 0: [Parameter] p#0 #-----| 0: [Parameter] p#0
#-----| Type = [RValueReferenceType] S && #-----| Type = [RValueReferenceType] S &&
# 9| [FunctionTemplateInstantiation,MemberFunction] int Bad::S::MemberFunction<int>(int) # 9| [FunctionTemplateInstantiation,MemberFunction] int Bad::S::MemberFunction<int 6>(int)
# 9| params: # 9| params:
# 9| 0: [Parameter] y # 9| 0: [Parameter] y
# 9| Type = [IntType] int # 9| Type = [IntType] int
@@ -92,7 +92,7 @@ bad_asts.cpp:
# 10| 1: [VariableAccess] y # 10| 1: [VariableAccess] y
# 10| Type = [IntType] int # 10| Type = [IntType] int
# 10| ValueCategory = prvalue(load) # 10| ValueCategory = prvalue(load)
# 9| [MemberFunction,TemplateFunction] int Bad::S::MemberFunction<int>(int) # 9| [MemberFunction,TemplateFunction] int Bad::S::MemberFunction<int t>(int)
# 9| params: # 9| params:
# 9| 0: [Parameter] y # 9| 0: [Parameter] y
# 9| Type = [IntType] int # 9| Type = [IntType] int
@@ -104,8 +104,9 @@ bad_asts.cpp:
# 10| 0: [AddExpr] ... + ... # 10| 0: [AddExpr] ... + ...
# 10| Type = [IntType] int # 10| Type = [IntType] int
# 10| ValueCategory = prvalue # 10| ValueCategory = prvalue
# 10| 0: [Literal] Unknown literal # 10| 0: [Literal] t
# 10| Type = [IntType] int # 10| Type = [IntType] int
# 10| Value = [Literal] t
# 10| ValueCategory = prvalue # 10| ValueCategory = prvalue
# 10| 1: [PointerFieldAccess] x # 10| 1: [PointerFieldAccess] x
# 10| Type = [IntType] int # 10| Type = [IntType] int

View File

@@ -1,5 +1,5 @@
bad_asts.cpp: bad_asts.cpp:
# 9| int Bad::S::MemberFunction<int>(int) # 9| int Bad::S::MemberFunction<int 6>(int)
# 9| Block 0 # 9| Block 0
# 9| v0_0(void) = EnterFunction : # 9| v0_0(void) = EnterFunction :
# 9| mu0_1(unknown) = AliasedDefinition : # 9| mu0_1(unknown) = AliasedDefinition :