@@ -1922,11 +1922,19 @@ void MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
1922
1922
if (WithScalarType)
1923
1923
mangleType (T, SourceRange (), QMM_Escape);
1924
1924
1925
- // We don't know how to mangle past-the-end pointers yet.
1926
- if (V.isLValueOnePastTheEnd ())
1927
- break ;
1928
-
1929
1925
APValue::LValueBase Base = V.getLValueBase ();
1926
+
1927
+ // this might not cover every case but did cover issue 97756
1928
+ // see test CodeGen/ms_mangler_templatearg_opte
1929
+ if (V.isLValueOnePastTheEnd ()) {
1930
+ Out << " 5E" ;
1931
+ auto *VD = Base.dyn_cast <const ValueDecl *>();
1932
+ if (VD)
1933
+ mangle (VD);
1934
+ Out << " @" ;
1935
+ return ;
1936
+ }
1937
+
1930
1938
if (!V.hasLValuePath () || V.getLValuePath ().empty ()) {
1931
1939
// Taking the address of a complete object has a special-case mangling.
1932
1940
if (Base.isNull ()) {
@@ -1938,12 +1946,23 @@ void MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
1938
1946
mangleNumber (V.getLValueOffset ().getQuantity ());
1939
1947
} else if (!V.hasLValuePath ()) {
1940
1948
// FIXME: This can only happen as an extension. Invent a mangling.
1941
- break ;
1949
+ DiagnosticsEngine &Diags = Context.getDiags ();
1950
+ unsigned DiagID =
1951
+ Diags.getCustomDiagID (DiagnosticsEngine::Error,
1952
+ " cannot mangle this template argument yet "
1953
+ " (extension not comaptible with ms mangler)" );
1954
+ Diags.Report (DiagID);
1955
+ return ;
1942
1956
} else if (auto *VD = Base.dyn_cast <const ValueDecl*>()) {
1943
1957
Out << " E" ;
1944
1958
mangle (VD);
1945
1959
} else {
1946
- break ;
1960
+ DiagnosticsEngine &Diags = Context.getDiags ();
1961
+ unsigned DiagID = Diags.getCustomDiagID (
1962
+ DiagnosticsEngine::Error,
1963
+ " cannot mangle this template argument yet (undeclared base)" );
1964
+ Diags.Report (DiagID);
1965
+ return ;
1947
1966
}
1948
1967
} else {
1949
1968
if (TAK == TplArgKind::ClassNTTP && T->isPointerType ())
@@ -1988,8 +2007,14 @@ void MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
1988
2007
Out << *I;
1989
2008
1990
2009
auto *VD = Base.dyn_cast <const ValueDecl*>();
1991
- if (!VD)
1992
- break ;
2010
+ if (!VD) {
2011
+ DiagnosticsEngine &Diags = Context.getDiags ();
2012
+ unsigned DiagID = Diags.getCustomDiagID (
2013
+ DiagnosticsEngine::Error,
2014
+ " cannot mangle this template argument yet (null value decl)" );
2015
+ Diags.Report (DiagID);
2016
+ return ;
2017
+ }
1993
2018
Out << (TAK == TplArgKind::ClassNTTP ? ' E' : ' 1' );
1994
2019
mangle (VD);
1995
2020
@@ -2104,15 +2129,24 @@ void MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
2104
2129
return ;
2105
2130
}
2106
2131
2107
- case APValue::AddrLabelDiff:
2108
- case APValue::FixedPoint:
2109
- break ;
2132
+ case APValue::AddrLabelDiff: {
2133
+ DiagnosticsEngine &Diags = Context.getDiags ();
2134
+ unsigned DiagID = Diags.getCustomDiagID (
2135
+ DiagnosticsEngine::Error, " cannot mangle this template argument yet "
2136
+ " (value type: address label diff)" );
2137
+ Diags.Report (DiagID);
2138
+ return ;
2110
2139
}
2111
2140
2112
- DiagnosticsEngine &Diags = Context.getDiags ();
2113
- unsigned DiagID = Diags.getCustomDiagID (
2114
- DiagnosticsEngine::Error, " cannot mangle this template argument yet" );
2115
- Diags.Report (DiagID);
2141
+ case APValue::FixedPoint: {
2142
+ DiagnosticsEngine &Diags = Context.getDiags ();
2143
+ unsigned DiagID = Diags.getCustomDiagID (
2144
+ DiagnosticsEngine::Error,
2145
+ " cannot mangle this template argument yet (value type: fixed point)" );
2146
+ Diags.Report (DiagID);
2147
+ return ;
2148
+ }
2149
+ }
2116
2150
}
2117
2151
2118
2152
void MicrosoftCXXNameMangler::mangleObjCProtocol (const ObjCProtocolDecl *PD) {
0 commit comments