24
24
#include " refactor/Rename.h"
25
25
#include " refactor/Tweak.h"
26
26
#ifdef INTERACTIVECCCONV
27
- #include " cconvert/CConvInteractive .h"
27
+ #include " clang/CConv/CConv .h"
28
28
#include " CConvertCommands.h"
29
29
#endif
30
30
#include " clang/Format/Format.h"
@@ -170,34 +170,36 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
170
170
}
171
171
172
172
#ifdef INTERACTIVECCCONV
173
- void ClangdServer::reportCConvDiagsForAllFiles (DisjointSet &ccInfo ,
173
+ void ClangdServer::reportCConvDiagsForAllFiles (DisjointSet &CcInfo ,
174
174
CConvLSPCallBack *ConvCB) {
175
175
// Update the diag information for all the valid files.
176
- for (auto &srcFileDiags : CConvDiagInfo.GetAllFilesDiagnostics ()) {
177
- ConvCB->ccConvResultsReady (srcFileDiags .first );
176
+ for (auto &SrcFileDiags : CConvDiagInfo.GetAllFilesDiagnostics ()) {
177
+ ConvCB->ccConvResultsReady (SrcFileDiags .first );
178
178
}
179
179
}
180
180
181
- void ClangdServer::clearCConvDiagsForAllFiles (DisjointSet &ccInfo ,
181
+ void ClangdServer::clearCConvDiagsForAllFiles (DisjointSet &CcInfo ,
182
182
CConvLSPCallBack *ConvCB) {
183
- for (auto &srcFileDiags : CConvDiagInfo.GetAllFilesDiagnostics ()) {
183
+ for (auto &SrcFileDiags : CConvDiagInfo.GetAllFilesDiagnostics ()) {
184
184
// Clear diags for all files.
185
- ConvCB->ccConvResultsReady (srcFileDiags .first , true );
185
+ ConvCB->ccConvResultsReady (SrcFileDiags .first , true );
186
186
}
187
187
}
188
188
189
- void ClangdServer::cconvCollectAndBuildInitialConstraints (CConvLSPCallBack *ConvCB) {
189
+ void
190
+ ClangdServer::cconvCollectAndBuildInitialConstraints (CConvLSPCallBack *ConvCB) {
190
191
auto Task = [=]() {
191
192
CConvDiagInfo.ClearAllDiags ();
192
193
ConvCB->sendCConvMessage (" Running CConv for first time." );
193
194
CConvInter.BuildInitialConstraints ();
195
+ CConvInter.SolveConstraints ();
194
196
ConvCB->sendCConvMessage (" Finished running CConv." );
195
197
log (" CConv: Built initial constraints successfully.\n " );
196
- auto &ccInterfaceInfo = CConvInter.GetWILDPtrsInfo ();
198
+ auto &WildPtrsInfo = CConvInter.GetWILDPtrsInfo ();
197
199
log (" CConv: Got WILD Ptrs Info.\n " );
198
- CConvDiagInfo.PopulateDiagsFromDisjointSet (ccInterfaceInfo );
200
+ CConvDiagInfo.PopulateDiagsFromDisjointSet (WildPtrsInfo );
199
201
log (" CConv: Populated Diags from Disjoint Sets.\n " );
200
- reportCConvDiagsForAllFiles (ccInterfaceInfo , ConvCB);
202
+ reportCConvDiagsForAllFiles (WildPtrsInfo , ConvCB);
201
203
ConvCB->sendCConvMessage (" CConv: Finished updating problems." );
202
204
log (" CConv: Updated the diag information.\n " );
203
205
};
@@ -207,37 +209,40 @@ void ClangdServer::cconvCollectAndBuildInitialConstraints(CConvLSPCallBack *Conv
207
209
void ClangdServer::executeCConvCommand (ExecuteCommandParams Params,
208
210
CConvLSPCallBack *ConvCB) {
209
211
auto Task = [this , Params, ConvCB]() {
210
- std::string replyMessage;
211
- auto &wildPtrInfo = CConvInter.GetWILDPtrsInfo ();
212
- auto &ptrSourceMap = wildPtrInfo.PtrSourceMap ;
213
- if (ptrSourceMap.find (Params.ccConvertManualFix ->ptrID ) != ptrSourceMap.end ()) {
214
- std::string ptrFileName = ptrSourceMap[Params.ccConvertManualFix ->ptrID ]->getFileName ();
215
- log (" CConv: File of the pointer {0}\n " , ptrFileName);
216
- clearCConvDiagsForAllFiles (wildPtrInfo, ConvCB);
212
+ std::string RplMsg;
213
+ auto &WildPtrsInfo = CConvInter.GetWILDPtrsInfo ();
214
+ auto &PtrSourceMap = WildPtrsInfo.PtrSourceMap ;
215
+ if (PtrSourceMap.find (Params.ccConvertManualFix ->ptrID ) !=
216
+ PtrSourceMap.end ()) {
217
+ std::string PtrFileName =
218
+ PtrSourceMap[Params.ccConvertManualFix ->ptrID ]->getFileName ();
219
+ log (" CConv: File of the pointer {0}\n " , PtrFileName);
220
+ clearCConvDiagsForAllFiles (WildPtrsInfo, ConvCB);
217
221
ConvCB->sendCConvMessage (" CConv modifying constraints." );
218
- ExecuteCCCommand (Params, replyMessage , CConvInter);
222
+ ExecuteCCCommand (Params, RplMsg , CConvInter);
219
223
this ->CConvDiagInfo .ClearAllDiags ();
220
- auto &ccInterfaceInfo = wildPtrInfo;
221
- ConvCB-> sendCConvMessage ( " CConv Updating new issues after editing constraints." );
222
- this ->CConvDiagInfo .PopulateDiagsFromDisjointSet (ccInterfaceInfo );
224
+ ConvCB-> sendCConvMessage ( " CConv Updating new issues "
225
+ " after editing constraints." );
226
+ this ->CConvDiagInfo .PopulateDiagsFromDisjointSet (WildPtrsInfo );
223
227
log (" CConv calling call-back\n " );
224
228
// ConvCB->ccConvResultsReady(ptrFileName);
225
229
ConvCB->sendCConvMessage (" CConv Updated new issues." );
226
- reportCConvDiagsForAllFiles (ccInterfaceInfo , ConvCB);
230
+ reportCConvDiagsForAllFiles (WildPtrsInfo , ConvCB);
227
231
} else {
228
232
ConvCB->sendCConvMessage (" CConv contraint key already removed." );
229
233
}
230
234
};
231
235
WorkScheduler.run (" Applying on demand ptr modifications" , Task);
232
236
}
233
237
234
- void ClangdServer::cconvCloseDocument (std::string file ) {
238
+ void ClangdServer::cconvCloseDocument (std::string FileName ) {
235
239
auto Task = [=]() {
236
- log (" CConv: Trying to write back file: {0}\n " , file );
237
- if (CConvInter.WriteConvertedFileToDisk (file )) {
238
- log (" CConv: Finished writing back file: {0}\n " , file );
240
+ log (" CConv: Trying to write back file: {0}\n " , FileName );
241
+ if (CConvInter.WriteConvertedFileToDisk (FileName )) {
242
+ log (" CConv: Finished writing back file: {0}\n " , FileName );
239
243
} else {
240
- log (" CConv: File not included during constraint solving phase. Rewriting failed: {0}\n " , file);
244
+ log (" CConv: File not included during constraint solving phase. "
245
+ " Rewriting failed: {0}\n " , FileName);
241
246
}
242
247
};
243
248
WorkScheduler.run (" CConv: Writing back file." , Task);
0 commit comments