1
+ #include " clang/AST/DeclCXX.h"
1
2
#include " clang/Basic/SourceLocation.h"
2
3
#include " clang/Basic/Specifiers.h"
3
4
#include " clang/Frontend/CompilerInstance.h"
7
8
#include " clang/Sema/OverloadCallback.h"
8
9
#include " clang/Sema/Sema.h"
9
10
#include " llvm/ADT/SmallString.h"
11
+ #include " llvm/Support/Casting.h"
10
12
#include " llvm/Support/YAMLTraits.h"
11
13
#include " llvm/Support/raw_ostream.h"
12
14
#include < algorithm>
@@ -70,7 +72,7 @@ struct OvInsCandEntry {
70
72
std::string name;
71
73
std::string usingLocation;
72
74
clang::SourceLocation usingLoc;
73
- OverloadCandidateRewriteKind rewriteKind;
75
+ OverloadCandidateRewriteKind rewriteKind=clang::CRK_None ;
74
76
std::deque<std::string> paramTypes;
75
77
OvInsSource src;
76
78
std::vector<OvInsTemplateSpec> templateSpecs;
@@ -1102,20 +1104,26 @@ class DefaultOverloadInstCallback : public OverloadCallback {
1102
1104
const auto callKinds = getCallKinds ();
1103
1105
const SetArgs &setArg = getSetArgs ();
1104
1106
bool isStaticCall = setArg.ObjectExpr == nullptr && C.IgnoreObjectArgument ;
1107
+ // if (C.Function && C.Function){isStaticCall=true;}
1105
1108
for (size_t i = 0 ; i < C.Conversions .size (); ++i) {
1106
1109
const ExprValueKind fromKind =
1107
1110
(callKinds.size () > i - isStaticCall)
1108
1111
? ((i >= isStaticCall) ? callKinds[i - isStaticCall] : VK_LValue)
1109
1112
: VK_LValue;
1110
1113
const auto &conv = C.Conversions [i];
1111
1114
OvInsConvEntry &actual = res[i];
1115
+ bool isDeduceThis=false ;
1112
1116
{
1113
1117
int inArgsIdx = i;
1114
- if ((C.Function && isa<CXXMethodDecl>(C.Function ) &&
1115
- !isa<CXXConstructorDecl>(C.Function ) && setArg.ObjectExpr ) ||
1116
- C.IsSurrogate )
1117
- --inArgsIdx;
1118
- actual.src = getConversionSource (setArg, inArgsIdx);
1118
+ if (auto * fp=llvm::dyn_cast_or_null<CXXMethodDecl>(C.Function )){
1119
+ isDeduceThis = fp->isExplicitObjectMemberFunction ();
1120
+ }
1121
+ if (!isDeduceThis)
1122
+ if ((C.Function && isa<CXXMethodDecl>(C.Function ) &&
1123
+ !isa<CXXConstructorDecl>(C.Function ) && setArg.ObjectExpr ) ||
1124
+ C.IsSurrogate )
1125
+ --inArgsIdx;
1126
+ actual.src = getConversionSource (setArg, inArgsIdx-isDeduceThis);
1119
1127
}
1120
1128
if (!conv.isInitialized ()) {
1121
1129
actual.kind = " Uninitialized" ;
@@ -1124,6 +1132,7 @@ class DefaultOverloadInstCallback : public OverloadCallback {
1124
1132
int idx = i;
1125
1133
if (C.isReversed ())
1126
1134
idx = 1 - idx;
1135
+ // if (!isDeduceThis)
1127
1136
if ((C.Function && isa<CXXMethodDecl>(C.Function ) &&
1128
1137
!isa<CXXConstructorDecl>(C.Function )) ||
1129
1138
C.IsSurrogate )
@@ -1138,7 +1147,7 @@ class DefaultOverloadInstCallback : public OverloadCallback {
1138
1147
if (C.Function && idx != -1 &&
1139
1148
!isa<clang::InitListExpr>(setArg.inArgs [idx]))
1140
1149
path << " -> "
1141
- << C.Function ->parameters ()[idx]
1150
+ << C.Function ->parameters ()[idx+isDeduceThis ]
1142
1151
->getType ()
1143
1152
.getCanonicalType ()
1144
1153
.getAsString ();
@@ -1204,6 +1213,7 @@ class DefaultOverloadInstCallback : public OverloadCallback {
1204
1213
if (temp != " " )
1205
1214
path << " = " << temp;
1206
1215
}
1216
+ // path << i<<" "<<idx;
1207
1217
}
1208
1218
1209
1219
return res;
@@ -1284,8 +1294,6 @@ class DefaultOverloadInstCallback : public OverloadCallback {
1284
1294
res.usingLoc .print (usingLoc, S->SourceMgr );
1285
1295
}
1286
1296
res.rewriteKind = C.getRewriteKind ();
1287
- if (!C.Function && !C.IsSurrogate )
1288
- res.rewriteKind = OverloadCandidateRewriteKind::CRK_None;
1289
1297
res.name = C.FoundDecl .getDecl ()->getQualifiedNameAsString ();
1290
1298
if (C.Function ) {
1291
1299
res.paramTypes = getParamTypes (C);
0 commit comments