svf-lib 1.0.1567 → 1.0.1569
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-linux/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-linux/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-linux/svf/include/SVFIR/SVFValue.h +7 -0
- package/SVF-linux/svf/include/Util/ExtAPI.h +209 -19
- package/SVF-linux/svf/include/Util/ExtAPI.json +125 -22
- package/SVF-linux/svf-llvm/include/SVF-LLVM/LLVMModule.h +1 -0
- package/SVF-linux/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +10 -5
- package/SVF-osx/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-osx/svf/include/CFL/CFGNormalizer.h +1 -1
- package/SVF-osx/svf/include/CFL/CFLAlias.h +2 -2
- package/SVF-osx/svf/include/CFL/CFLBase.h +3 -0
- package/SVF-osx/svf/include/CFL/CFLGramGraphChecker.h +10 -10
- package/SVF-osx/svf/include/CFL/CFLGrammar.h +29 -29
- package/SVF-osx/svf/include/CFL/CFLGraphBuilder.h +68 -44
- package/SVF-osx/svf/include/CFL/CFLVF.h +3 -0
- package/SVF-osx/svf/include/Util/Options.h +1 -0
- package/SVF-osx/svf/include/Util/SVFUtil.h +12 -5
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -218,6 +218,10 @@ public:
|
|
|
218
218
|
{
|
|
219
219
|
return name;
|
|
220
220
|
}
|
|
221
|
+
inline virtual void setName(const std::string& valueName)
|
|
222
|
+
{
|
|
223
|
+
name = valueName;
|
|
224
|
+
}
|
|
221
225
|
|
|
222
226
|
inline virtual const SVFType* getType() const
|
|
223
227
|
{
|
|
@@ -266,6 +270,7 @@ class SVFFunction : public SVFValue
|
|
|
266
270
|
friend class LLVMModuleSet;
|
|
267
271
|
friend class SVFIRWriter;
|
|
268
272
|
friend class SVFIRReader;
|
|
273
|
+
friend class SVFIRBuilder;
|
|
269
274
|
|
|
270
275
|
public:
|
|
271
276
|
typedef std::vector<const SVFBasicBlock*>::const_iterator const_iterator;
|
|
@@ -482,6 +487,7 @@ class SVFBasicBlock : public SVFValue
|
|
|
482
487
|
friend class LLVMModuleSet;
|
|
483
488
|
friend class SVFIRWriter;
|
|
484
489
|
friend class SVFIRReader;
|
|
490
|
+
friend class SVFIRBuilder;
|
|
485
491
|
|
|
486
492
|
public:
|
|
487
493
|
typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
|
|
@@ -650,6 +656,7 @@ class SVFCallInst : public SVFInstruction
|
|
|
650
656
|
friend class SVFIRWriter;
|
|
651
657
|
friend class SVFIRReader;
|
|
652
658
|
friend class LLVMModuleSet;
|
|
659
|
+
friend class SVFIRBuilder;
|
|
653
660
|
|
|
654
661
|
private:
|
|
655
662
|
std::vector<const SVFValue*> args;
|
|
@@ -224,38 +224,227 @@ private:
|
|
|
224
224
|
|
|
225
225
|
public:
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
enum OperationType
|
|
228
228
|
{
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
Addr,
|
|
230
|
+
Copy,
|
|
231
|
+
Load,
|
|
232
|
+
Store,
|
|
233
|
+
Gep,
|
|
234
|
+
Call,
|
|
235
|
+
Return,
|
|
236
|
+
Rb_tree_ops,
|
|
237
|
+
Memcpy_like,
|
|
238
|
+
Memset_like,
|
|
239
|
+
Other
|
|
240
|
+
};
|
|
233
241
|
|
|
234
|
-
|
|
242
|
+
class Operand
|
|
243
|
+
{
|
|
244
|
+
public:
|
|
245
|
+
OperationType getType() const
|
|
235
246
|
{
|
|
236
|
-
return
|
|
247
|
+
return opType;
|
|
237
248
|
}
|
|
238
|
-
|
|
239
|
-
std::vector<std::string> getOperandStr()
|
|
249
|
+
void setType(OperationType type)
|
|
240
250
|
{
|
|
241
|
-
|
|
251
|
+
opType = type;
|
|
242
252
|
}
|
|
243
|
-
|
|
244
|
-
|
|
253
|
+
const std::string &getSrcValue() const
|
|
254
|
+
{
|
|
255
|
+
return src;
|
|
256
|
+
}
|
|
257
|
+
void setSrcValue(const std::string &value)
|
|
258
|
+
{
|
|
259
|
+
src = value;
|
|
260
|
+
}
|
|
261
|
+
const std::string &getDstValue() const
|
|
262
|
+
{
|
|
263
|
+
return dst;
|
|
264
|
+
}
|
|
265
|
+
void setDstValue(const std::string &value)
|
|
266
|
+
{
|
|
267
|
+
dst = value;
|
|
268
|
+
}
|
|
269
|
+
NodeID getSrcID() const
|
|
270
|
+
{
|
|
271
|
+
return srcID;
|
|
272
|
+
}
|
|
273
|
+
void setSrcID(NodeID id)
|
|
274
|
+
{
|
|
275
|
+
srcID = id;
|
|
276
|
+
}
|
|
277
|
+
NodeID getDstID() const
|
|
278
|
+
{
|
|
279
|
+
return dstID;
|
|
280
|
+
}
|
|
281
|
+
void setDstID(NodeID id)
|
|
282
|
+
{
|
|
283
|
+
dstID = id;
|
|
284
|
+
}
|
|
285
|
+
const std::string &getOffsetOrSizeStr() const
|
|
245
286
|
{
|
|
246
|
-
return
|
|
287
|
+
return offsetOrSizeStr;
|
|
247
288
|
}
|
|
289
|
+
void setOffsetOrSizeStr(const std::string &str)
|
|
290
|
+
{
|
|
291
|
+
offsetOrSizeStr = str;
|
|
292
|
+
}
|
|
293
|
+
u32_t getOffsetOrSize() const
|
|
294
|
+
{
|
|
295
|
+
return offsetOrSize;
|
|
296
|
+
}
|
|
297
|
+
void setOffsetOrSize(u32_t off)
|
|
298
|
+
{
|
|
299
|
+
offsetOrSize = off;
|
|
300
|
+
}
|
|
301
|
+
private:
|
|
302
|
+
OperationType opType; // 操作数类型
|
|
303
|
+
std::string src; // 操作数值
|
|
304
|
+
std::string dst; //
|
|
305
|
+
std::string offsetOrSizeStr; // Gep
|
|
306
|
+
NodeID srcID;
|
|
307
|
+
NodeID dstID;
|
|
308
|
+
u32_t offsetOrSize;
|
|
309
|
+
};
|
|
248
310
|
|
|
249
|
-
|
|
311
|
+
class ExtOperation
|
|
312
|
+
{
|
|
313
|
+
public:
|
|
314
|
+
bool isCallOp() const
|
|
315
|
+
{
|
|
316
|
+
return callOp;
|
|
317
|
+
}
|
|
318
|
+
void setCallOp(bool isCall)
|
|
319
|
+
{
|
|
320
|
+
callOp = isCall;
|
|
321
|
+
}
|
|
322
|
+
bool isConOp() const
|
|
323
|
+
{
|
|
324
|
+
return conOp;
|
|
325
|
+
}
|
|
326
|
+
void setConOp(bool isCon)
|
|
327
|
+
{
|
|
328
|
+
conOp = isCon;
|
|
329
|
+
}
|
|
330
|
+
Operand& getBasicOp()
|
|
331
|
+
{
|
|
332
|
+
return basicOp;
|
|
333
|
+
}
|
|
334
|
+
void setBasicOp(Operand op)
|
|
335
|
+
{
|
|
336
|
+
basicOp = op;
|
|
337
|
+
}
|
|
338
|
+
const std::string &getCondition() const
|
|
339
|
+
{
|
|
340
|
+
return condition;
|
|
341
|
+
}
|
|
342
|
+
void setCondition(const std::string &cond)
|
|
343
|
+
{
|
|
344
|
+
condition = cond;
|
|
345
|
+
}
|
|
346
|
+
std::vector<Operand>& getTrueBranchOperands()
|
|
347
|
+
{
|
|
348
|
+
return trueBranch_operands;
|
|
349
|
+
}
|
|
350
|
+
void setTrueBranchOperands(std::vector<Operand> tbo)
|
|
351
|
+
{
|
|
352
|
+
trueBranch_operands = tbo;
|
|
353
|
+
}
|
|
354
|
+
std::vector<Operand>& getFalseBranchOperands()
|
|
355
|
+
{
|
|
356
|
+
return falseBranch_operands;
|
|
357
|
+
}
|
|
358
|
+
void setFalseBranchOperands(std::vector<Operand> fbo)
|
|
359
|
+
{
|
|
360
|
+
falseBranch_operands = fbo;
|
|
361
|
+
}
|
|
362
|
+
const std::string &getCalleeName() const
|
|
363
|
+
{
|
|
364
|
+
return callee_name;
|
|
365
|
+
}
|
|
366
|
+
void setCalleeName(const std::string &name)
|
|
367
|
+
{
|
|
368
|
+
callee_name = name;
|
|
369
|
+
}
|
|
370
|
+
const std::string &getCalleeReturn() const
|
|
371
|
+
{
|
|
372
|
+
return callee_return;
|
|
373
|
+
}
|
|
374
|
+
void setCalleeReturn(const std::string &ret)
|
|
375
|
+
{
|
|
376
|
+
callee_return = ret;
|
|
377
|
+
}
|
|
378
|
+
const std::string &getCalleeArguments() const
|
|
379
|
+
{
|
|
380
|
+
return callee_arguments;
|
|
381
|
+
}
|
|
382
|
+
void setCalleeArguments(const std::string &args)
|
|
383
|
+
{
|
|
384
|
+
callee_arguments = args;
|
|
385
|
+
}
|
|
386
|
+
std::vector<Operand>& getCalleeOperands()
|
|
250
387
|
{
|
|
251
|
-
|
|
388
|
+
return callee_operands;
|
|
252
389
|
}
|
|
390
|
+
void setCalleeOperands(std::vector<Operand> ops)
|
|
391
|
+
{
|
|
392
|
+
callee_operands = ops;
|
|
393
|
+
}
|
|
394
|
+
private:
|
|
395
|
+
bool callOp = false;
|
|
396
|
+
bool conOp = false;
|
|
397
|
+
Operand basicOp;
|
|
398
|
+
std::string condition;
|
|
399
|
+
std::vector<Operand> trueBranch_operands;
|
|
400
|
+
std::vector<Operand> falseBranch_operands;
|
|
401
|
+
std::string callee_name;
|
|
402
|
+
std::string callee_return;
|
|
403
|
+
std::string callee_arguments;
|
|
404
|
+
std::vector<Operand> callee_operands;
|
|
405
|
+
};
|
|
253
406
|
|
|
407
|
+
class ExtFunctionOps
|
|
408
|
+
{
|
|
409
|
+
public:
|
|
410
|
+
ExtFunctionOps() {};
|
|
411
|
+
ExtFunctionOps(const std::string &name, std::vector<ExtOperation> ops) : extFunName(name), extOperations(ops) {};
|
|
412
|
+
const std::string &getExtFunName() const
|
|
413
|
+
{
|
|
414
|
+
return extFunName;
|
|
415
|
+
}
|
|
416
|
+
void setExtFunName(const std::string &name)
|
|
417
|
+
{
|
|
418
|
+
extFunName = name;
|
|
419
|
+
}
|
|
420
|
+
std::vector<ExtOperation>& getOperations()
|
|
421
|
+
{
|
|
422
|
+
return extOperations;
|
|
423
|
+
}
|
|
424
|
+
void setOperations(std::vector<ExtOperation> ops)
|
|
425
|
+
{
|
|
426
|
+
extOperations = ops;
|
|
427
|
+
}
|
|
428
|
+
u32_t getCallStmtNum()
|
|
429
|
+
{
|
|
430
|
+
return callStmtNum;
|
|
431
|
+
}
|
|
432
|
+
void setCallStmtNum(u32_t num)
|
|
433
|
+
{
|
|
434
|
+
callStmtNum = num;
|
|
435
|
+
}
|
|
254
436
|
private:
|
|
255
|
-
std::string
|
|
256
|
-
std::vector<
|
|
257
|
-
|
|
437
|
+
std::string extFunName;
|
|
438
|
+
std::vector<ExtOperation> extOperations;
|
|
439
|
+
u32_t callStmtNum = 0;
|
|
258
440
|
};
|
|
441
|
+
|
|
442
|
+
private:
|
|
443
|
+
// Map an external function to its operations
|
|
444
|
+
std::map<std::string, ExtFunctionOps> extFunToOps;
|
|
445
|
+
|
|
446
|
+
public:
|
|
447
|
+
|
|
259
448
|
static ExtAPI *getExtAPI(const std::string& = "");
|
|
260
449
|
|
|
261
450
|
static void destory();
|
|
@@ -291,7 +480,8 @@ public:
|
|
|
291
480
|
cJSON *get_FunJson(const std::string &funName);
|
|
292
481
|
|
|
293
482
|
// Get all operations of an extern function
|
|
294
|
-
|
|
483
|
+
Operand getBasicOperation(cJSON* obj);
|
|
484
|
+
ExtFunctionOps getExtFunctionOps(std::string funName);
|
|
295
485
|
|
|
296
486
|
// Get property of the operation, e.g. "EFT_A1R_A0R"
|
|
297
487
|
extType get_type(const SVF::SVFFunction *callee);
|
|
@@ -4990,35 +4990,55 @@
|
|
|
4990
4990
|
"arguments": "(i8*, i8, i32, i32, i1)",
|
|
4991
4991
|
"type": "EFT_L_A0__A0R_A1",
|
|
4992
4992
|
"overwrite_app_function": 0,
|
|
4993
|
-
"memset_like":
|
|
4993
|
+
"memset_like": {
|
|
4994
|
+
"src": "Arg0",
|
|
4995
|
+
"dst": "Arg1",
|
|
4996
|
+
"size": "Arg2"
|
|
4997
|
+
}
|
|
4994
4998
|
},
|
|
4995
4999
|
"llvm.memset.p0i8.i32": {
|
|
4996
5000
|
"return": "void",
|
|
4997
5001
|
"arguments": "(i8*, i8, i32, i32, i1)",
|
|
4998
5002
|
"type": "EFT_L_A0__A0R_A1",
|
|
4999
5003
|
"overwrite_app_function": 0,
|
|
5000
|
-
"memset_like":
|
|
5004
|
+
"memset_like": {
|
|
5005
|
+
"src": "Arg0",
|
|
5006
|
+
"dst": "Arg1",
|
|
5007
|
+
"size": "Arg2"
|
|
5008
|
+
}
|
|
5001
5009
|
},
|
|
5002
5010
|
"llvm.memset.p0i8.i64": {
|
|
5003
5011
|
"return": "void",
|
|
5004
5012
|
"arguments": "(i8*, i8, i64, i32, i1)",
|
|
5005
5013
|
"type": "EFT_L_A0__A0R_A1",
|
|
5006
5014
|
"overwrite_app_function": 0,
|
|
5007
|
-
"memset_like":
|
|
5015
|
+
"memset_like": {
|
|
5016
|
+
"src": "Arg0",
|
|
5017
|
+
"dst": "Arg1",
|
|
5018
|
+
"size": "Arg2"
|
|
5019
|
+
}
|
|
5008
5020
|
},
|
|
5009
5021
|
"__memset_chk": {
|
|
5010
5022
|
"return": "void *",
|
|
5011
5023
|
"arguments": "(void *, int, size_t, size_t)",
|
|
5012
5024
|
"type": "EFT_L_A0__A0R_A1",
|
|
5013
5025
|
"overwrite_app_function": 0,
|
|
5014
|
-
"memset_like":
|
|
5026
|
+
"memset_like": {
|
|
5027
|
+
"src": "Arg0",
|
|
5028
|
+
"dst": "Arg1",
|
|
5029
|
+
"size": "Arg2"
|
|
5030
|
+
}
|
|
5015
5031
|
},
|
|
5016
5032
|
"llvm.memcpy": {
|
|
5017
5033
|
"return": "void",
|
|
5018
5034
|
"arguments": "(i8*, i8*, i32, i32, i1)",
|
|
5019
5035
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5020
5036
|
"overwrite_app_function": 0,
|
|
5021
|
-
"memcpy_like":
|
|
5037
|
+
"memcpy_like": {
|
|
5038
|
+
"src": "Arg0",
|
|
5039
|
+
"dst": "Arg1",
|
|
5040
|
+
"size": "Arg2"
|
|
5041
|
+
},
|
|
5022
5042
|
"CopyStmt": {
|
|
5023
5043
|
"src": "Arg0",
|
|
5024
5044
|
"dst": "Ret"
|
|
@@ -5029,7 +5049,11 @@
|
|
|
5029
5049
|
"arguments": "(i8*, i8*, i32, i32, i1)",
|
|
5030
5050
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5031
5051
|
"overwrite_app_function": 0,
|
|
5032
|
-
"memcpy_like":
|
|
5052
|
+
"memcpy_like": {
|
|
5053
|
+
"src": "Arg0",
|
|
5054
|
+
"dst": "Arg1",
|
|
5055
|
+
"size": "Arg2"
|
|
5056
|
+
},
|
|
5033
5057
|
"CopyStmt": {
|
|
5034
5058
|
"src": "Arg0",
|
|
5035
5059
|
"dst": "Ret"
|
|
@@ -5040,7 +5064,11 @@
|
|
|
5040
5064
|
"arguments": "(i8*, *i8, i64, i32, i1)",
|
|
5041
5065
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5042
5066
|
"overwrite_app_function": 0,
|
|
5043
|
-
"memcpy_like":
|
|
5067
|
+
"memcpy_like": {
|
|
5068
|
+
"src": "Arg0",
|
|
5069
|
+
"dst": "Arg1",
|
|
5070
|
+
"size": "Arg2"
|
|
5071
|
+
},
|
|
5044
5072
|
"CopyStmt": {
|
|
5045
5073
|
"src": "Arg0",
|
|
5046
5074
|
"dst": "Ret"
|
|
@@ -5051,7 +5079,11 @@
|
|
|
5051
5079
|
"arguments": "(i8*, i8*, i32, i1)",
|
|
5052
5080
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5053
5081
|
"overwrite_app_function": 0,
|
|
5054
|
-
"memcpy_like":
|
|
5082
|
+
"memcpy_like": {
|
|
5083
|
+
"src": "Arg0",
|
|
5084
|
+
"dst": "Arg1",
|
|
5085
|
+
"size": "Arg2"
|
|
5086
|
+
},
|
|
5055
5087
|
"CopyStmt": {
|
|
5056
5088
|
"src": "Arg0",
|
|
5057
5089
|
"dst": "Ret"
|
|
@@ -5062,7 +5094,11 @@
|
|
|
5062
5094
|
"arguments": "(i8*, i8*, i32, i1)",
|
|
5063
5095
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5064
5096
|
"overwrite_app_function": 0,
|
|
5065
|
-
"memcpy_like":
|
|
5097
|
+
"memcpy_like": {
|
|
5098
|
+
"src": "Arg0",
|
|
5099
|
+
"dst": "Arg1",
|
|
5100
|
+
"size": "Arg2"
|
|
5101
|
+
},
|
|
5066
5102
|
"CopyStmt": {
|
|
5067
5103
|
"src": "Arg0",
|
|
5068
5104
|
"dst": "Ret"
|
|
@@ -5073,7 +5109,11 @@
|
|
|
5073
5109
|
"arguments": "(i8*, i8*, i64, i1)",
|
|
5074
5110
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5075
5111
|
"overwrite_app_function": 0,
|
|
5076
|
-
"memcpy_like":
|
|
5112
|
+
"memcpy_like": {
|
|
5113
|
+
"src": "Arg0",
|
|
5114
|
+
"dst": "Arg1",
|
|
5115
|
+
"size": "Arg2"
|
|
5116
|
+
},
|
|
5077
5117
|
"CopyStmt": {
|
|
5078
5118
|
"src": "Arg0",
|
|
5079
5119
|
"dst": "Ret"
|
|
@@ -5084,7 +5124,11 @@
|
|
|
5084
5124
|
"arguments": "(void *restrict, const void *restrict, int, size_t)",
|
|
5085
5125
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5086
5126
|
"overwrite_app_function": 0,
|
|
5087
|
-
"memcpy_like":
|
|
5127
|
+
"memcpy_like": {
|
|
5128
|
+
"src": "Arg0",
|
|
5129
|
+
"dst": "Arg1",
|
|
5130
|
+
"size": "Arg2"
|
|
5131
|
+
},
|
|
5088
5132
|
"CopyStmt": {
|
|
5089
5133
|
"src": "Arg0",
|
|
5090
5134
|
"dst": "Ret"
|
|
@@ -5095,7 +5139,11 @@
|
|
|
5095
5139
|
"arguments": "(void *, const void *, size_t)",
|
|
5096
5140
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5097
5141
|
"overwrite_app_function": 0,
|
|
5098
|
-
"memcpy_like":
|
|
5142
|
+
"memcpy_like": {
|
|
5143
|
+
"src": "Arg0",
|
|
5144
|
+
"dst": "Arg1",
|
|
5145
|
+
"size": "Arg2"
|
|
5146
|
+
},
|
|
5099
5147
|
"CopyStmt": {
|
|
5100
5148
|
"src": "Arg0",
|
|
5101
5149
|
"dst": "Ret"
|
|
@@ -5106,7 +5154,11 @@
|
|
|
5106
5154
|
"arguments": "(void *, const void *, size_t)",
|
|
5107
5155
|
"type": "EFT_L_A0__A0R_A1R",
|
|
5108
5156
|
"overwrite_app_function": 0,
|
|
5109
|
-
"memcpy_like":
|
|
5157
|
+
"memcpy_like": {
|
|
5158
|
+
"src": "Arg0",
|
|
5159
|
+
"dst": "Arg1",
|
|
5160
|
+
"size": "Arg2"
|
|
5161
|
+
},
|
|
5110
5162
|
"CopyStmt": {
|
|
5111
5163
|
"src": "Arg0",
|
|
5112
5164
|
"dst": "Ret"
|
|
@@ -5117,14 +5169,21 @@
|
|
|
5117
5169
|
"arguments": "(const void *, void *, size_t)",
|
|
5118
5170
|
"type": "EFT_A1R_A0R",
|
|
5119
5171
|
"overwrite_app_function": 0,
|
|
5120
|
-
"memcpy_like":
|
|
5172
|
+
"memcpy_like": {
|
|
5173
|
+
"src": "Arg1",
|
|
5174
|
+
"dst": "Arg0",
|
|
5175
|
+
"size": "Arg2"
|
|
5176
|
+
}
|
|
5121
5177
|
},
|
|
5122
5178
|
"iconv": {
|
|
5123
5179
|
"return": "size_t",
|
|
5124
5180
|
"arguments": "(iconv_t, char **restrict, size_t *restrict, char **restrict, size_t *restrict)",
|
|
5125
5181
|
"type": "EFT_A3R_A1R_NS",
|
|
5126
5182
|
"overwrite_app_function": 0,
|
|
5127
|
-
"memcpy_like":
|
|
5183
|
+
"memcpy_like": {
|
|
5184
|
+
"src": "Arg3",
|
|
5185
|
+
"dst": "Arg1"
|
|
5186
|
+
}
|
|
5128
5187
|
},
|
|
5129
5188
|
"strtod": {
|
|
5130
5189
|
"return": "double",
|
|
@@ -5201,7 +5260,11 @@
|
|
|
5201
5260
|
"arguments": "(char *, const char *, size_t)",
|
|
5202
5261
|
"type": "EFT_L_A0__A1_A0",
|
|
5203
5262
|
"overwrite_app_function": 0,
|
|
5204
|
-
"memcpy_like":
|
|
5263
|
+
"memcpy_like": {
|
|
5264
|
+
"src": "Arg0",
|
|
5265
|
+
"dst": "Arg1",
|
|
5266
|
+
"size": "Arg2"
|
|
5267
|
+
},
|
|
5205
5268
|
"CopyStmt": {
|
|
5206
5269
|
"src": "Arg0",
|
|
5207
5270
|
"dst": "Ret"
|
|
@@ -5212,7 +5275,11 @@
|
|
|
5212
5275
|
"arguments": "(char *, const char *, size_t)",
|
|
5213
5276
|
"type": "EFT_L_A0__A1_A0",
|
|
5214
5277
|
"overwrite_app_function": 0,
|
|
5215
|
-
"memcpy_like":
|
|
5278
|
+
"memcpy_like": {
|
|
5279
|
+
"src": "Arg0",
|
|
5280
|
+
"dst": "Arg1",
|
|
5281
|
+
"size": "Arg2"
|
|
5282
|
+
},
|
|
5216
5283
|
"CopyStmt": {
|
|
5217
5284
|
"src": "Arg0",
|
|
5218
5285
|
"dst": "Ret"
|
|
@@ -5223,7 +5290,10 @@
|
|
|
5223
5290
|
"arguments": "(char *restrict, const char *restrict)",
|
|
5224
5291
|
"type": "EFT_L_A0__A1_A0",
|
|
5225
5292
|
"overwrite_app_function": 0,
|
|
5226
|
-
"memcpy_like":
|
|
5293
|
+
"memcpy_like": {
|
|
5294
|
+
"src": "Arg0",
|
|
5295
|
+
"dst": "Arg1"
|
|
5296
|
+
},
|
|
5227
5297
|
"CopyStmt": {
|
|
5228
5298
|
"src": "Arg0",
|
|
5229
5299
|
"dst": "Ret"
|
|
@@ -5234,7 +5304,10 @@
|
|
|
5234
5304
|
"arguments": "(char *, char *)",
|
|
5235
5305
|
"type": "EFT_L_A0__A1_A0",
|
|
5236
5306
|
"overwrite_app_function": 0,
|
|
5237
|
-
"memcpy_like":
|
|
5307
|
+
"memcpy_like": {
|
|
5308
|
+
"src": "Arg0",
|
|
5309
|
+
"dst": "Arg1"
|
|
5310
|
+
},
|
|
5238
5311
|
"CopyStmt": {
|
|
5239
5312
|
"src": "Arg0",
|
|
5240
5313
|
"dst": "Ret"
|
|
@@ -5245,7 +5318,10 @@
|
|
|
5245
5318
|
"arguments": "(char *, const char *)",
|
|
5246
5319
|
"type": "EFT_L_A0__A1_A0",
|
|
5247
5320
|
"overwrite_app_function": 0,
|
|
5248
|
-
"memcpy_like":
|
|
5321
|
+
"memcpy_like": {
|
|
5322
|
+
"src": "Arg0",
|
|
5323
|
+
"dst": "Arg1"
|
|
5324
|
+
},
|
|
5249
5325
|
"CopyStmt": {
|
|
5250
5326
|
"src": "Arg0",
|
|
5251
5327
|
"dst": "Ret"
|
|
@@ -5256,7 +5332,11 @@
|
|
|
5256
5332
|
"arguments": "(char *, const char *, size_t)",
|
|
5257
5333
|
"type": "EFT_L_A0__A1_A0",
|
|
5258
5334
|
"overwrite_app_function": 0,
|
|
5259
|
-
"memcpy_like":
|
|
5335
|
+
"memcpy_like": {
|
|
5336
|
+
"src": "Arg0",
|
|
5337
|
+
"dst": "Arg1",
|
|
5338
|
+
"size": "Arg2"
|
|
5339
|
+
},
|
|
5260
5340
|
"CopyStmt": {
|
|
5261
5341
|
"src": "Arg0",
|
|
5262
5342
|
"dst": "Ret"
|
|
@@ -5267,7 +5347,11 @@
|
|
|
5267
5347
|
"arguments": "(char *, const char *, size_t)",
|
|
5268
5348
|
"type": "EFT_L_A0__A1_A0",
|
|
5269
5349
|
"overwrite_app_function": 0,
|
|
5270
|
-
"memcpy_like":
|
|
5350
|
+
"memcpy_like": {
|
|
5351
|
+
"src": "Arg0",
|
|
5352
|
+
"dst": "Arg1",
|
|
5353
|
+
"size": "Arg2"
|
|
5354
|
+
},
|
|
5271
5355
|
"CopyStmt": {
|
|
5272
5356
|
"src": "Arg0",
|
|
5273
5357
|
"dst": "Ret"
|
|
@@ -5726,5 +5810,24 @@
|
|
|
5726
5810
|
"src": "NullPtr",
|
|
5727
5811
|
"dst": "Dummy"
|
|
5728
5812
|
}
|
|
5813
|
+
},
|
|
5814
|
+
"swapExtCallStmt":{
|
|
5815
|
+
"return": "void",
|
|
5816
|
+
"arguments": "(char **, char **)",
|
|
5817
|
+
"type": "EFT_NOOP",
|
|
5818
|
+
"overwrite_app_function": 0,
|
|
5819
|
+
"CallStmt": {
|
|
5820
|
+
"callee_name": "swap",
|
|
5821
|
+
"callee_return": "void",
|
|
5822
|
+
"callee_arguments": "(char **, char **)",
|
|
5823
|
+
"CopyStmt1": {
|
|
5824
|
+
"src": "swapExtCallStmt_Arg0",
|
|
5825
|
+
"dst": "swap_Arg0"
|
|
5826
|
+
},
|
|
5827
|
+
"CopyStmt2": {
|
|
5828
|
+
"src": "swapExtCallStmt_Arg1",
|
|
5829
|
+
"dst": "swap_Arg1"
|
|
5830
|
+
}
|
|
5831
|
+
}
|
|
5729
5832
|
}
|
|
5730
5833
|
}
|
|
@@ -224,9 +224,6 @@ protected:
|
|
|
224
224
|
/// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
|
|
225
225
|
const Value* getBaseValueForExtArg(const Value* V);
|
|
226
226
|
|
|
227
|
-
/// Get the base type and max offset
|
|
228
|
-
const Type* getBaseTypeAndFlattenedFields(const Value* V, std::vector<LocationSet> &fields, const Value* sz);
|
|
229
|
-
|
|
230
227
|
/// Handle direct call
|
|
231
228
|
void handleDirectCall(CallBase* cs, const Function *F);
|
|
232
229
|
|
|
@@ -235,9 +232,17 @@ protected:
|
|
|
235
232
|
|
|
236
233
|
/// Handle external call
|
|
237
234
|
//@{
|
|
238
|
-
virtual
|
|
235
|
+
virtual SVFCallInst* addSVFExtCallInst(const SVFCallInst* svfInst, SVFBasicBlock* svfBB, const SVFFunction* svfCaller, const SVFFunction* svfCallee);
|
|
236
|
+
virtual void addSVFExtRetInst(SVFCallInst* svfCall, SVFBasicBlock* svfBB, SVFFunction* svfCaller);
|
|
237
|
+
virtual SVFInstruction* addSVFExtInst(const std::string& instName, const SVFCallInst* svfInst, SVFBasicBlock* svfBB, SVF::ExtAPI::OperationType opType, const SVFType* svfType);
|
|
238
|
+
virtual void extFuncAtomaticOperation(ExtAPI::Operand& atomicOp, const SVFCallInst* svfInst);
|
|
239
|
+
virtual SVFBasicBlock* extFuncInitialization(const SVFCallInst* svfInst, SVFFunction* svfCaller);
|
|
240
|
+
virtual void handleExtCallStat(ExtAPI::ExtFunctionOps &extFunctionOps, const SVFCallInst* svfInst);
|
|
241
|
+
virtual NodeID getExtID(ExtAPI::OperationType operationType, const std::string &s, const SVFCallInst* svfCall);
|
|
242
|
+
virtual void parseAtomaticOp(SVF::ExtAPI::Operand &atomaticOp, const SVFCallInst* svfCall, std::map<std::string, NodeID> &nodeIDMap);
|
|
243
|
+
virtual void parseExtFunctionOps(ExtAPI::ExtFunctionOps &extFunctionOps, const SVFCallInst* svfCall);
|
|
239
244
|
virtual void preProcessExtCall(CallBase* cs);
|
|
240
|
-
virtual void handleExtCall(SVFInstruction*
|
|
245
|
+
virtual void handleExtCall(const SVFInstruction* svfInst, const SVFFunction* svfCallee);
|
|
241
246
|
void addComplexConsForExt(const SVFValue* D, const SVFValue* S, const SVFValue* sz);
|
|
242
247
|
//@}
|
|
243
248
|
|
|
Binary file
|
|
Binary file
|
|
@@ -56,7 +56,7 @@ public:
|
|
|
56
56
|
CFLGrammar* normalize(GrammarBase *generalGrammar);
|
|
57
57
|
|
|
58
58
|
/// Expand every variable attribute in rawProductions of grammarbase
|
|
59
|
-
CFLGrammar* fillAttribute(CFLGrammar *grammar, const Map<CFLGrammar::Kind, Set<CFLGrammar::Attribute>>&
|
|
59
|
+
CFLGrammar* fillAttribute(CFLGrammar *grammar, const Map<CFLGrammar::Kind, Set<CFLGrammar::Attribute>>& kindToAttrsMap);
|
|
60
60
|
|
|
61
61
|
private:
|
|
62
62
|
/// Add nonterminal to tranfer long rules to binary rules
|
|
@@ -112,8 +112,8 @@ public:
|
|
|
112
112
|
{
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
115
|
-
CFLGrammar::Kind copyKind = grammar->
|
|
116
|
-
CFLGrammar::Kind copybarKind = grammar->
|
|
115
|
+
CFLGrammar::Kind copyKind = grammar->strToKind("copy");
|
|
116
|
+
CFLGrammar::Kind copybarKind = grammar->strToKind("copybar");
|
|
117
117
|
solver->pushIntoWorklist(graph->addCFLEdge(graph->getGNode(src),graph->getGNode(dst), copyKind));
|
|
118
118
|
solver->pushIntoWorklist(graph->addCFLEdge(graph->getGNode(dst),graph->getGNode(src), copybarKind));
|
|
119
119
|
return true;
|
|
@@ -42,29 +42,29 @@ public:
|
|
|
42
42
|
/// Check all kinds in grammar in graphBuilder with the same label
|
|
43
43
|
for(auto pairV : grammar->getTerminals())
|
|
44
44
|
{
|
|
45
|
-
if (graphBuilder->
|
|
45
|
+
if (graphBuilder->getLabelToKindMap().find(pairV.first) != graphBuilder->getLabelToKindMap().end())
|
|
46
46
|
{
|
|
47
|
-
assert(graphBuilder->
|
|
48
|
-
assert(graphBuilder->
|
|
47
|
+
assert(graphBuilder->getLabelToKindMap()[pairV.first] == pairV.second);
|
|
48
|
+
assert(graphBuilder->getKindToLabelMap()[pairV.second] == pairV.first);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
for(auto pairV : grammar->getNonterminals())
|
|
53
53
|
{
|
|
54
|
-
if (graphBuilder->
|
|
54
|
+
if (graphBuilder->getLabelToKindMap().find(pairV.first) != graphBuilder->getLabelToKindMap().end())
|
|
55
55
|
{
|
|
56
|
-
assert(graphBuilder->
|
|
57
|
-
assert(graphBuilder->
|
|
56
|
+
assert(graphBuilder->getLabelToKindMap()[pairV.first] == pairV.second);
|
|
57
|
+
assert(graphBuilder->getKindToLabelMap()[pairV.second] == pairV.first);
|
|
58
58
|
}
|
|
59
59
|
else
|
|
60
60
|
{
|
|
61
|
-
graphBuilder->
|
|
62
|
-
graphBuilder->
|
|
61
|
+
graphBuilder->getLabelToKindMap().insert(std::make_pair (pairV.first,pairV.second));
|
|
62
|
+
graphBuilder->getKindToLabelMap().insert(std::make_pair (pairV.second, pairV.first));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/// Get
|
|
67
|
-
grammar->
|
|
66
|
+
/// Get KindToAttrs Map from Graph to Grammar
|
|
67
|
+
grammar->setKindToAttrsMap(graphBuilder->getKindToAttrsMap());
|
|
68
68
|
graph->startKind = grammar->getStartKind();
|
|
69
69
|
}
|
|
70
70
|
};
|
|
@@ -192,9 +192,9 @@ public:
|
|
|
192
192
|
return this->rawProductions;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
inline const Map<Kind, Set<Attribute>>&
|
|
195
|
+
inline const Map<Kind, Set<Attribute>>& getKindToAttrsMap() const
|
|
196
196
|
{
|
|
197
|
-
return this->
|
|
197
|
+
return this->kindToAttrsMap;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
inline Kind getTotalKind()
|
|
@@ -223,17 +223,17 @@ public:
|
|
|
223
223
|
|
|
224
224
|
void setRawProductions(SymbolMap<Symbol, Productions>& rawProductions);
|
|
225
225
|
|
|
226
|
-
void
|
|
226
|
+
void setKindToAttrsMap(const Map<Kind, Set<Attribute>>& kindToAttrsMap);
|
|
227
227
|
|
|
228
228
|
void setAttributeKinds(const Set<Kind>& attributeKind);
|
|
229
229
|
|
|
230
|
-
Kind
|
|
230
|
+
Kind strToKind(std::string str) const;
|
|
231
231
|
|
|
232
|
-
Symbol
|
|
232
|
+
Symbol strToSymbol(const std::string str) const;
|
|
233
233
|
|
|
234
|
-
std::string
|
|
234
|
+
std::string kindToStr(Kind kind) const;
|
|
235
235
|
|
|
236
|
-
std::string
|
|
236
|
+
std::string symToStrDump(Symbol sym) const;
|
|
237
237
|
|
|
238
238
|
Symbol getSymbol(const Production& prod, u32_t pos)
|
|
239
239
|
{
|
|
@@ -282,7 +282,7 @@ private:
|
|
|
282
282
|
Map<std::string, Kind> terminals;
|
|
283
283
|
Map<std::string, Kind> EBNFSigns; /// Map contains Signs' String and associated Symbols
|
|
284
284
|
Set<Kind> attributeKinds;
|
|
285
|
-
Map<Kind, Set<Attribute>>
|
|
285
|
+
Map<Kind, Set<Attribute>> kindToAttrsMap;
|
|
286
286
|
SymbolMap<Symbol, Productions> rawProductions;
|
|
287
287
|
u32_t totalKind;
|
|
288
288
|
};
|
|
@@ -310,57 +310,57 @@ public:
|
|
|
310
310
|
return epsilonProds;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
SymbolMap<Symbol, Productions>&
|
|
313
|
+
SymbolMap<Symbol, Productions>& getSingleRHSToProds()
|
|
314
314
|
{
|
|
315
|
-
return
|
|
315
|
+
return singleRHSToProds;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
SymbolMap<Symbol, Productions>&
|
|
318
|
+
SymbolMap<Symbol, Productions>& getFirstRHSToProds()
|
|
319
319
|
{
|
|
320
|
-
return
|
|
320
|
+
return firstRHSToProds;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
SymbolMap<Symbol, Productions>&
|
|
323
|
+
SymbolMap<Symbol, Productions>& getSecondRHSToProds()
|
|
324
324
|
{
|
|
325
|
-
return
|
|
325
|
+
return secondRHSToProds;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
const bool hasProdsFromFirstRHS(const Symbol sym) const
|
|
329
329
|
{
|
|
330
|
-
auto it =
|
|
331
|
-
return it!=
|
|
330
|
+
auto it = firstRHSToProds.find(sym);
|
|
331
|
+
return it!=firstRHSToProds.end();
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
const bool hasProdsFromSingleRHS(const Symbol sym) const
|
|
335
335
|
{
|
|
336
|
-
auto it =
|
|
337
|
-
return it!=
|
|
336
|
+
auto it = singleRHSToProds.find(sym);
|
|
337
|
+
return it!=singleRHSToProds.end();
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
const bool hasProdsFromSecondRHS(const Symbol sym) const
|
|
341
341
|
{
|
|
342
|
-
auto it =
|
|
343
|
-
return it!=
|
|
342
|
+
auto it = secondRHSToProds.find(sym);
|
|
343
|
+
return it!=secondRHSToProds.end();
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
const Productions& getProdsFromSingleRHS(const Symbol sym) const
|
|
347
347
|
{
|
|
348
|
-
auto it =
|
|
349
|
-
assert(it!=
|
|
348
|
+
auto it = singleRHSToProds.find(sym);
|
|
349
|
+
assert(it!=singleRHSToProds.end() && "production (X -> sym) not found for sym!!");
|
|
350
350
|
return it->second;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
const Productions& getProdsFromFirstRHS(const Symbol sym) const
|
|
354
354
|
{
|
|
355
|
-
auto it =
|
|
356
|
-
assert(it!=
|
|
355
|
+
auto it = firstRHSToProds.find(sym);
|
|
356
|
+
assert(it!=firstRHSToProds.end() && "production (X -> sym Y ) not found for sym!!");
|
|
357
357
|
return it->second;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
const Productions& getProdsFromSecondRHS(const Symbol sym) const
|
|
361
361
|
{
|
|
362
|
-
auto it =
|
|
363
|
-
assert(it!=
|
|
362
|
+
auto it = secondRHSToProds.find(sym);
|
|
363
|
+
assert(it!=secondRHSToProds.end() && "production (X -> Y sym) not found for sym!!");
|
|
364
364
|
return it->second;
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -392,9 +392,9 @@ public:
|
|
|
392
392
|
|
|
393
393
|
private:
|
|
394
394
|
SymbolSet<Production> epsilonProds;
|
|
395
|
-
SymbolMap<Symbol, Productions>
|
|
396
|
-
SymbolMap<Symbol, Productions>
|
|
397
|
-
SymbolMap<Symbol, Productions>
|
|
395
|
+
SymbolMap<Symbol, Productions> singleRHSToProds;
|
|
396
|
+
SymbolMap<Symbol, Productions> firstRHSToProds;
|
|
397
|
+
SymbolMap<Symbol, Productions> secondRHSToProds;
|
|
398
398
|
u32_t newTerminalSubscript;
|
|
399
399
|
};
|
|
400
400
|
|
|
@@ -37,27 +37,40 @@
|
|
|
37
37
|
namespace SVF
|
|
38
38
|
{
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
|
|
40
|
+
/**
|
|
41
|
+
* CFLGraphBuilder class is responsible for building CFL (Context-Free Language) graphs
|
|
42
|
+
* from text files or dot files or from memory graph.
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
44
|
class CFLGraphBuilder
|
|
46
45
|
{
|
|
47
46
|
protected:
|
|
47
|
+
/// Define Kind(Not contain attribute) and Symbol(May contain attribute) as types derived from CFLGrammar
|
|
48
|
+
/// to numerically represent label
|
|
48
49
|
typedef CFLGrammar::Kind Kind;
|
|
49
50
|
typedef CFLGrammar::Symbol Symbol;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Map<
|
|
53
|
-
|
|
51
|
+
|
|
52
|
+
/// Maps to maintain mapping between labels and kinds
|
|
53
|
+
Map<std::string, Kind> labelToKindMap;
|
|
54
|
+
Map<Kind, std::string> kindToLabelMap;
|
|
55
|
+
|
|
56
|
+
/// Map to maintain attributes associated with each kind
|
|
57
|
+
Map<CFLGrammar::Kind, Set<CFLGrammar::Attribute>> kindToAttrsMap;
|
|
58
|
+
|
|
54
59
|
Kind current;
|
|
60
|
+
CFLGraph *cflGraph;
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
/// add attribute to kind2Attribute Map
|
|
62
|
+
/// Method to add an attribute to a specific kind
|
|
58
63
|
void addAttribute(CFLGrammar::Kind kind, CFLGrammar::Attribute attribute);
|
|
59
64
|
|
|
60
|
-
///
|
|
65
|
+
/// build label and kind connect from the grammar
|
|
66
|
+
void buildlabelToKindMap(GrammarBase *grammar);
|
|
67
|
+
|
|
68
|
+
/// add src and dst node from file
|
|
69
|
+
CFLNode* addGNode(u32_t NodeID);
|
|
70
|
+
|
|
71
|
+
public:
|
|
72
|
+
/// Method to build a CFL graph by copying nodes and edges from any graph
|
|
73
|
+
/// inherited from GenericGraph
|
|
61
74
|
template<class N, class E>
|
|
62
75
|
void build(GenericGraph<N,E>* graph, CFLGraph* cflGraph)
|
|
63
76
|
{
|
|
@@ -76,32 +89,32 @@ public:
|
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
|
|
79
|
-
///
|
|
92
|
+
/// Method to build a bidirectional CFL graph by copying nodes and edges
|
|
93
|
+
/// from any graph inherited from GenericGraph
|
|
80
94
|
template<class N, class E>
|
|
81
95
|
CFLGraph* buildBigraph(GenericGraph<N,E>* graph, Kind startKind, GrammarBase *grammar)
|
|
82
96
|
{
|
|
83
97
|
CFLGraph *cflGraph = new CFLGraph(startKind);
|
|
84
|
-
externMap = true;
|
|
85
98
|
for(auto pairV : grammar->getTerminals())
|
|
86
99
|
{
|
|
87
|
-
if(
|
|
100
|
+
if(labelToKindMap.find(pairV.first) == labelToKindMap.end())
|
|
88
101
|
{
|
|
89
|
-
|
|
102
|
+
labelToKindMap.insert(pairV);
|
|
90
103
|
}
|
|
91
|
-
if(
|
|
104
|
+
if(kindToLabelMap.find(pairV.second) == kindToLabelMap.end())
|
|
92
105
|
{
|
|
93
|
-
|
|
106
|
+
kindToLabelMap.insert(make_pair(pairV.second, pairV.first));
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
for(auto pairV : grammar->getNonterminals())
|
|
97
110
|
{
|
|
98
|
-
if(
|
|
111
|
+
if(labelToKindMap.find(pairV.first) == labelToKindMap.end())
|
|
99
112
|
{
|
|
100
|
-
|
|
113
|
+
labelToKindMap.insert(pairV);
|
|
101
114
|
}
|
|
102
|
-
if(
|
|
115
|
+
if(kindToLabelMap.find(pairV.second) == kindToLabelMap.end())
|
|
103
116
|
{
|
|
104
|
-
|
|
117
|
+
kindToLabelMap.insert(make_pair(pairV.second, pairV.first));
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
for(auto it = graph->begin(); it!= graph->end(); it++)
|
|
@@ -116,78 +129,89 @@ public:
|
|
|
116
129
|
{
|
|
117
130
|
CFLGrammar::Kind edgeLabel = edge->getEdgeKind();
|
|
118
131
|
cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
|
|
119
|
-
std::string key =
|
|
132
|
+
std::string key = kindToLabelMap[edge->getEdgeKind()];
|
|
120
133
|
key.append("bar");
|
|
121
|
-
cflGraph->addCFLEdge(cflGraph->getGNode(edge->getDstID()), cflGraph->getGNode(edge->getSrcID()),
|
|
134
|
+
cflGraph->addCFLEdge(cflGraph->getGNode(edge->getDstID()), cflGraph->getGNode(edge->getSrcID()), labelToKindMap[key]);
|
|
122
135
|
}
|
|
123
136
|
}
|
|
124
137
|
return cflGraph;
|
|
125
138
|
}
|
|
126
139
|
|
|
127
|
-
///
|
|
128
|
-
void build(std::string filename, CFLGraph* cflGraph);
|
|
129
|
-
|
|
130
|
-
/// Build graph from Dot
|
|
140
|
+
/// Method to build a CFL graph from a Dot file
|
|
131
141
|
CFLGraph *buildFromDot(std::string filename, GrammarBase *grammar);
|
|
132
142
|
|
|
133
|
-
|
|
143
|
+
/// Method to build a CFL graph from a Text file
|
|
144
|
+
CFLGraph* buildFromTextFile(std::string fileName, GrammarBase *grammar);
|
|
145
|
+
|
|
146
|
+
/// @{
|
|
147
|
+
/// Getter methods for accessing class variables
|
|
148
|
+
|
|
149
|
+
/// Returns a reference to the map that associates string labels with their corresponding Kind
|
|
150
|
+
Map<std::string, Kind>& getLabelToKindMap()
|
|
134
151
|
{
|
|
135
|
-
return this->
|
|
152
|
+
return this->labelToKindMap;
|
|
136
153
|
}
|
|
137
154
|
|
|
138
|
-
|
|
155
|
+
/// Returns a reference to the map that associates Kinds with their corresponding string labels
|
|
156
|
+
Map<Kind, std::string>& getKindToLabelMap()
|
|
139
157
|
{
|
|
140
|
-
return this->
|
|
158
|
+
return this->kindToLabelMap;
|
|
141
159
|
}
|
|
142
160
|
|
|
143
|
-
|
|
161
|
+
/// Returns a reference to the map that associates Kinds with their corresponding attributes
|
|
162
|
+
Map<CFLGrammar::Kind, Set<CFLGrammar::Attribute>>& getKindToAttrsMap()
|
|
144
163
|
{
|
|
145
|
-
return this->
|
|
164
|
+
return this->kindToAttrsMap;
|
|
146
165
|
}
|
|
147
166
|
|
|
148
|
-
|
|
167
|
+
/// @}
|
|
149
168
|
};
|
|
150
169
|
|
|
170
|
+
/// AliasCFLGraphBuilder: a CFLGraphBuilder specialized for handling aliasing
|
|
151
171
|
class AliasCFLGraphBuilder : public CFLGraphBuilder
|
|
152
172
|
{
|
|
153
173
|
public:
|
|
154
|
-
///
|
|
174
|
+
/// Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from GenericGraph
|
|
155
175
|
CFLGraph* buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar);
|
|
156
176
|
|
|
157
|
-
///
|
|
158
|
-
///
|
|
177
|
+
/// Builds a bidirectional CFL graph by copying nodes and edges from any graph that inherits from GenericGraph
|
|
178
|
+
/// Transfers Load and Store to copy edge and address edge to construct PEG style CFLGraph
|
|
159
179
|
CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
|
|
160
180
|
|
|
161
181
|
private:
|
|
182
|
+
/// Connects VGep (Variable GEP)
|
|
162
183
|
void connectVGep(CFLGraph *cflGraph, ConstraintGraph *graph, ConstraintNode *src, ConstraintNode *dst, u32_t level, SVFIR* pag);
|
|
163
184
|
|
|
164
|
-
///
|
|
185
|
+
/// Handles edges, with the exception of the GEP
|
|
165
186
|
void addBiCFLEdge(CFLGraph *cflGraph, ConstraintNode* src, ConstraintNode* dst, CFLGrammar::Kind label);
|
|
166
187
|
|
|
167
|
-
///
|
|
188
|
+
/// Adds bidirectional GEP edges with attributes
|
|
168
189
|
void addBiGepCFLEdge(CFLGraph *cflGraph, ConstraintNode* src, ConstraintNode* dst, CFLGrammar::Attribute attri);
|
|
169
190
|
};
|
|
170
191
|
|
|
192
|
+
/// VFCFLGraphBuilder: a CFLGraphBuilder specialized for handling value-flow
|
|
171
193
|
class VFCFLGraphBuilder : public CFLGraphBuilder
|
|
172
194
|
{
|
|
173
195
|
public:
|
|
174
|
-
///
|
|
196
|
+
/// Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from SVFG
|
|
175
197
|
CFLGraph* buildBigraph(SVFG *graph, Kind startKind, GrammarBase *grammar);
|
|
176
198
|
|
|
177
|
-
///
|
|
178
|
-
///
|
|
199
|
+
/// Builds a bidirectional CFL graph by copying nodes and edges from any graph that inherits from GenericGraph
|
|
200
|
+
/// Transfers Load and Store to copy edge and address edge to construct PEG style CFLGraph
|
|
179
201
|
CFLGraph* buildBiPEGgraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR* pag);
|
|
180
202
|
|
|
181
203
|
private:
|
|
204
|
+
/// Connects VGep (Variable GEP)
|
|
182
205
|
void connectVGep(CFLGraph *cflGraph, ConstraintGraph *graph, ConstraintNode *src, ConstraintNode *dst, u32_t level, SVFIR* pag);
|
|
183
206
|
|
|
184
|
-
///
|
|
207
|
+
/// Handles edges, with the exception of the GEP
|
|
185
208
|
void addBiCFLEdge(CFLGraph *cflGraph, ConstraintNode* src, ConstraintNode* dst, CFLGrammar::Kind label);
|
|
186
209
|
|
|
187
|
-
///
|
|
210
|
+
/// Adds bidirectional GEP edges with attributes
|
|
188
211
|
void addBiGepCFLEdge(CFLGraph *cflGraph, ConstraintNode* src, ConstraintNode* dst, CFLGrammar::Attribute attri);
|
|
189
212
|
};
|
|
190
213
|
|
|
214
|
+
|
|
191
215
|
}// SVF
|
|
192
216
|
|
|
193
217
|
#endif /* INCLUDE_CFL_CFLGRAPHBUILDER_H_*/
|
|
@@ -215,17 +215,24 @@ inline CallSite getSVFCallSite(const SVFValue* value)
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/// Split into two substrings around the first occurrence of a separator string.
|
|
218
|
-
inline std::vector<std::string> split(const std::string& s, char
|
|
218
|
+
inline std::vector<std::string> split(const std::string& s, char separator)
|
|
219
219
|
{
|
|
220
220
|
std::vector<std::string> output;
|
|
221
221
|
std::string::size_type prev_pos = 0, pos = 0;
|
|
222
|
-
while((pos = s.find(
|
|
222
|
+
while ((pos = s.find(separator, pos)) != std::string::npos)
|
|
223
223
|
{
|
|
224
|
-
std::string substring(
|
|
225
|
-
|
|
224
|
+
std::string substring(s.substr(prev_pos, pos - prev_pos));
|
|
225
|
+
if (!substring.empty())
|
|
226
|
+
{
|
|
227
|
+
output.push_back(substring);
|
|
228
|
+
}
|
|
226
229
|
prev_pos = ++pos;
|
|
227
230
|
}
|
|
228
|
-
|
|
231
|
+
std::string lastSubstring(s.substr(prev_pos, pos - prev_pos));
|
|
232
|
+
if (!lastSubstring.empty())
|
|
233
|
+
{
|
|
234
|
+
output.push_back(lastSubstring);
|
|
235
|
+
}
|
|
229
236
|
return output;
|
|
230
237
|
}
|
|
231
238
|
|