svf-tools 1.0.372 → 1.0.376
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-doxygen/html/html/AndersenSFR_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/AndersenStat_8cpp_source.html +5 -6
- package/SVF-doxygen/html/html/Andersen_8cpp_source.html +10 -10
- package/SVF-doxygen/html/html/CHGBuilder_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/Conditions_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/ConsGEdge_8h_source.html +1 -1
- package/SVF-doxygen/html/html/ConsG_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/ConsG_8h_source.html +7 -7
- package/SVF-doxygen/html/html/ContextDDA_8cpp_source.html +6 -6
- package/SVF-doxygen/html/html/DDAClient_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/DDAClient_8h_source.html +1 -1
- package/SVF-doxygen/html/html/DDAPass_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/DDAVFSolver_8h_source.html +15 -15
- package/SVF-doxygen/html/html/FlowDDA_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/FlowSensitiveStat_8cpp_source.html +7 -7
- package/SVF-doxygen/html/html/FlowSensitiveTBHC_8cpp_source.html +7 -7
- package/SVF-doxygen/html/html/FlowSensitive_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/Graph2Json_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/ICFG_8cpp_source.html +4 -10
- package/SVF-doxygen/html/html/IRAnnotator_8h_source.html +3 -3
- package/SVF-doxygen/html/html/IRGraph_8cpp_source.html +6 -6
- package/SVF-doxygen/html/html/IRGraph_8h_source.html +2 -2
- package/SVF-doxygen/html/html/LLVMUtil_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/LLVMUtil_8h.html +3 -3
- package/SVF-doxygen/html/html/LLVMUtil_8h_source.html +2 -2
- package/SVF-doxygen/html/html/LeakChecker_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/LocationSet_8cpp_source.html +11 -11
- package/SVF-doxygen/html/html/LocationSet_8h_source.html +10 -11
- package/SVF-doxygen/html/html/MemRegion_8cpp_source.html +10 -10
- package/SVF-doxygen/html/html/OfflineConsG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/Options_8cpp_source.html +22 -21
- package/SVF-doxygen/html/html/Options_8h_source.html +22 -21
- package/SVF-doxygen/html/html/PAGBuilderFromFile_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/PTAStat_8cpp_source.html +17 -17
- package/SVF-doxygen/html/html/PathCondAllocator_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/PointerAnalysisImpl_8cpp_source.html +8 -8
- package/SVF-doxygen/html/html/PointerAnalysisImpl_8h_source.html +2 -2
- package/SVF-doxygen/html/html/PointerAnalysis_8cpp_source.html +11 -11
- package/SVF-doxygen/html/html/PointerAnalysis_8h_source.html +14 -14
- package/SVF-doxygen/html/html/SVFG_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/SVFIRBuilder_8cpp_source.html +8 -10
- package/SVF-doxygen/html/html/SVFIRBuilder_8h_source.html +72 -73
- package/SVF-doxygen/html/html/SVFIR_8cpp_source.html +37 -35
- package/SVF-doxygen/html/html/SVFIR_8h_source.html +66 -68
- package/SVF-doxygen/html/html/SVFModule_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/SVFStatements_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/SVFStatements_8h_source.html +5 -5
- package/SVF-doxygen/html/html/SVFUtil_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/SVFVariables_8cpp_source.html +18 -19
- package/SVF-doxygen/html/html/SVFVariables_8h_source.html +121 -127
- package/SVF-doxygen/html/html/SaberSVFGBuilder_8cpp_source.html +6 -6
- package/SVF-doxygen/html/html/SrcSnkDDA_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/SymbolTableBuilder_8cpp_source.html +39 -30
- package/SVF-doxygen/html/html/SymbolTableBuilder_8h_source.html +10 -7
- package/SVF-doxygen/html/html/SymbolTableInfo_8cpp_source.html +93 -53
- package/SVF-doxygen/html/html/SymbolTableInfo_8h_source.html +82 -85
- package/SVF-doxygen/html/html/ThreadCallGraph_8cpp_source.html +5 -5
- package/SVF-doxygen/html/html/TypeAnalysis_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/TypeBasedHeapCloning_8cpp_source.html +17 -16
- package/SVF-doxygen/html/html/TypeBasedHeapCloning_8h_source.html +1 -1
- package/SVF-doxygen/html/html/VFGNode_8h_source.html +2 -2
- package/SVF-doxygen/html/html/VFG_8cpp_source.html +7 -7
- package/SVF-doxygen/html/html/VFG_8h_source.html +2 -2
- package/SVF-doxygen/html/html/VersionedFlowSensitiveStat_8cpp_source.html +4 -4
- package/SVF-doxygen/html/html/VersionedFlowSensitive_8cpp_source.html +4 -4
- package/SVF-doxygen/html/html/WPAPass_8cpp_source.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1ActualParmVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1ActualRetVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1AliasDDAClient.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1Andersen.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1AndersenBase.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1AndersenSFR.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1AndersenStat.html +5 -6
- package/SVF-doxygen/html/html/classSVF_1_1ArgumentVFGNode.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +12 -13
- package/SVF-doxygen/html/html/classSVF_1_1BinaryOPVFGNode.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1BranchCondManager.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1BranchStmt.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1CHGBuilder.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1CloneDummyObjVar-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1CloneDummyObjVar.html +16 -25
- package/SVF-doxygen/html/html/classSVF_1_1CloneFIObjVar-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1CloneFIObjVar.html +17 -26
- package/SVF-doxygen/html/html/classSVF_1_1CloneGepObjVar-members.html +23 -26
- package/SVF-doxygen/html/html/classSVF_1_1CloneGepObjVar.html +17 -26
- package/SVF-doxygen/html/html/classSVF_1_1CmpVFGNode.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1CondPTAImpl.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintGraph.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1ContextDDA.html +6 -6
- package/SVF-doxygen/html/html/classSVF_1_1DDAClient.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1DDAPass.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1DDAVFSolver.html +12 -12
- package/SVF-doxygen/html/html/classSVF_1_1DummyObjVar-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1DummyObjVar.html +18 -27
- package/SVF-doxygen/html/html/classSVF_1_1DummyValVar-members.html +21 -24
- package/SVF-doxygen/html/html/classSVF_1_1DummyValVar.html +18 -27
- package/SVF-doxygen/html/html/classSVF_1_1FIObjVar-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1FIObjVar.html +19 -28
- package/SVF-doxygen/html/html/classSVF_1_1FlowDDA.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitive.html +10 -10
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveStat.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveTBHC.html +17 -17
- package/SVF-doxygen/html/html/classSVF_1_1FormalParmVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1FormalRetVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1FunptrDDAClient.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1GepObjVar-members.html +24 -27
- package/SVF-doxygen/html/html/classSVF_1_1GepObjVar.html +42 -51
- package/SVF-doxygen/html/html/classSVF_1_1GepStmt.html +12 -12
- package/SVF-doxygen/html/html/classSVF_1_1GepValVar-members.html +30 -35
- package/SVF-doxygen/html/html/classSVF_1_1GepValVar.html +34 -106
- package/SVF-doxygen/html/html/classSVF_1_1ICFGPrinter.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1IRGraph.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1InterPHIVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1IntraPHIVFGNode.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1LeakChecker.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1LocationSet-members.html +15 -16
- package/SVF-doxygen/html/html/classSVF_1_1LocationSet.html +47 -81
- package/SVF-doxygen/html/html/classSVF_1_1MRGenerator.html +12 -12
- package/SVF-doxygen/html/html/classSVF_1_1MemObj.html +87 -87
- package/SVF-doxygen/html/html/classSVF_1_1NormalGepCGEdge.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1NullPtrVFGNode.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1ObjTypeInfo-members.html +7 -8
- package/SVF-doxygen/html/html/classSVF_1_1ObjTypeInfo.html +162 -211
- package/SVF-doxygen/html/html/classSVF_1_1ObjVar-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1ObjVar.html +23 -32
- package/SVF-doxygen/html/html/classSVF_1_1OfflineConsG.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1Options-members.html +55 -54
- package/SVF-doxygen/html/html/classSVF_1_1Options.html +47 -21
- package/SVF-doxygen/html/html/classSVF_1_1PAGBuilderFromFile.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1PHIVFGNode.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1PTAStat.html +18 -18
- package/SVF-doxygen/html/html/classSVF_1_1PathCondAllocator.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +30 -30
- package/SVF-doxygen/html/html/classSVF_1_1RetPN-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1RetPN.html +18 -27
- package/SVF-doxygen/html/html/classSVF_1_1SVFG.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1SVFIR-members.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1SVFIR.html +214 -227
- package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder-members.html +82 -83
- package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder.html +582 -529
- package/SVF-doxygen/html/html/classSVF_1_1SVFModule.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1SVFVar-members.html +23 -26
- package/SVF-doxygen/html/html/classSVF_1_1SVFVar.html +54 -151
- package/SVF-doxygen/html/html/classSVF_1_1SaberSVFGBuilder.html +6 -6
- package/SVF-doxygen/html/html/classSVF_1_1SrcSnkDDA.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1StInfo.html +43 -43
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder-members.html +10 -7
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder.html +182 -72
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo-members.html +9 -11
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo.html +131 -162
- package/SVF-doxygen/html/html/classSVF_1_1ThreadCallGraph.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1TypeAnalysis.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1TypeBasedHeapCloning.html +26 -25
- package/SVF-doxygen/html/html/classSVF_1_1UnaryOPVFGNode.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1VFG.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1ValVar-members.html +21 -24
- package/SVF-doxygen/html/html/classSVF_1_1ValVar.html +16 -25
- package/SVF-doxygen/html/html/classSVF_1_1VarArgPN-members.html +22 -25
- package/SVF-doxygen/html/html/classSVF_1_1VarArgPN.html +18 -27
- package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitive.html +7 -7
- package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitiveStat.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1WPAPass.html +12 -12
- package/SVF-doxygen/html/html/functions_a.html +24 -24
- package/SVF-doxygen/html/html/functions_c.html +1 -1
- package/SVF-doxygen/html/html/functions_f.html +19 -22
- package/SVF-doxygen/html/html/functions_func.html +24 -24
- package/SVF-doxygen/html/html/functions_func_c.html +1 -1
- package/SVF-doxygen/html/html/functions_func_g.html +20 -23
- package/SVF-doxygen/html/html/functions_func_h.html +1 -1
- package/SVF-doxygen/html/html/functions_func_i.html +11 -17
- package/SVF-doxygen/html/html/functions_func_l.html +2 -2
- package/SVF-doxygen/html/html/functions_func_o.html +4 -4
- package/SVF-doxygen/html/html/functions_func_r.html +5 -2
- package/SVF-doxygen/html/html/functions_g.html +18 -21
- package/SVF-doxygen/html/html/functions_h.html +1 -1
- package/SVF-doxygen/html/html/functions_i.html +12 -21
- package/SVF-doxygen/html/html/functions_l.html +8 -8
- package/SVF-doxygen/html/html/functions_m.html +4 -1
- package/SVF-doxygen/html/html/functions_o.html +22 -18
- package/SVF-doxygen/html/html/functions_p.html +3 -3
- package/SVF-doxygen/html/html/functions_r.html +5 -2
- package/SVF-doxygen/html/html/functions_rela.html +2 -1
- package/SVF-doxygen/html/html/functions_s.html +6 -5
- package/SVF-doxygen/html/html/functions_t.html +4 -4
- package/SVF-doxygen/html/html/functions_v.html +3 -3
- package/SVF-doxygen/html/html/functions_vars_f.html +0 -3
- package/SVF-doxygen/html/html/functions_vars_i.html +3 -6
- package/SVF-doxygen/html/html/functions_vars_m.html +3 -0
- package/SVF-doxygen/html/html/namespaceSVF.html +1 -1
- package/SVF-doxygen/html/html/namespaceSVF_1_1SVFUtil.html +8 -8
- package/SVF-doxygen/html/html/namespacemembers_func.html +1 -1
- package/SVF-doxygen/html/html/namespacemembers_s.html +1 -1
- package/SVF-doxygen/html/html/search/all_1.js +22 -22
- package/SVF-doxygen/html/html/search/all_10.js +4 -4
- package/SVF-doxygen/html/html/search/all_12.js +5 -4
- package/SVF-doxygen/html/html/search/all_13.js +6 -6
- package/SVF-doxygen/html/html/search/all_14.js +4 -4
- package/SVF-doxygen/html/html/search/all_15.js +1 -1
- package/SVF-doxygen/html/html/search/all_16.js +1 -1
- package/SVF-doxygen/html/html/search/all_3.js +1 -1
- package/SVF-doxygen/html/html/search/all_6.js +0 -1
- package/SVF-doxygen/html/html/search/all_7.js +9 -9
- package/SVF-doxygen/html/html/search/all_8.js +1 -1
- package/SVF-doxygen/html/html/search/all_9.js +2 -5
- package/SVF-doxygen/html/html/search/all_c.js +4 -4
- package/SVF-doxygen/html/html/search/all_d.js +1 -0
- package/SVF-doxygen/html/html/search/all_e.js +3 -3
- package/SVF-doxygen/html/html/search/all_f.js +3 -3
- package/SVF-doxygen/html/html/search/functions_0.js +22 -22
- package/SVF-doxygen/html/html/search/functions_10.js +2 -2
- package/SVF-doxygen/html/html/search/functions_2.js +1 -1
- package/SVF-doxygen/html/html/search/functions_6.js +9 -9
- package/SVF-doxygen/html/html/search/functions_7.js +1 -1
- package/SVF-doxygen/html/html/search/functions_8.js +1 -3
- package/SVF-doxygen/html/html/search/functions_a.js +1 -1
- package/SVF-doxygen/html/html/search/functions_d.js +1 -1
- package/SVF-doxygen/html/html/search/functions_e.js +1 -1
- package/SVF-doxygen/html/html/search/functions_f.js +1 -0
- package/SVF-doxygen/html/html/search/related_9.js +1 -1
- package/SVF-doxygen/html/html/search/variables_14.js +2 -2
- package/SVF-doxygen/html/html/search/variables_15.js +1 -1
- package/SVF-doxygen/html/html/search/variables_6.js +0 -1
- package/SVF-doxygen/html/html/search/variables_9.js +1 -2
- package/SVF-doxygen/html/html/search/variables_d.js +1 -0
- package/SVF-doxygen/html/html/search/variables_e.js +2 -2
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01ConstraintGraph_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01ICFG_01_5_01_4.html +7 -21
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01IRGraph_01_5_01_4.html +3 -3
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01OfflineConsG_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/structstd_1_1hash_3_01SVF_1_1LocationSet_01_4.html +4 -4
- package/SVF-doxygen/html/html/svf-ex_8cpp.html +2 -2
- package/SVF-doxygen/html/html/svf-ex_8cpp_source.html +2 -2
- package/include/MemoryModel/LocationSet.h +0 -6
- package/include/MemoryModel/SVFIR.h +5 -37
- package/include/MemoryModel/SVFStatements.h +1 -1
- package/include/MemoryModel/SVFVariables.h +4 -21
- package/include/MemoryModel/SymbolTableInfo.h +8 -24
- package/include/SVF-FE/LLVMUtil.h +1 -1
- package/include/SVF-FE/SVFIRBuilder.h +91 -108
- package/include/SVF-FE/SymbolTableBuilder.h +9 -2
- package/include/Util/Options.h +1 -0
- package/lib/Graphs/ICFG.cpp +1 -47
- package/lib/MemoryModel/LocationSet.cpp +7 -3
- package/lib/MemoryModel/PointerAnalysisImpl.cpp +1 -1
- package/lib/MemoryModel/SVFIR.cpp +61 -19
- package/lib/MemoryModel/SVFVariables.cpp +6 -13
- package/lib/MemoryModel/SymbolTableInfo.cpp +57 -68
- package/lib/SVF-FE/LLVMUtil.cpp +3 -3
- package/lib/SVF-FE/SVFIRBuilder.cpp +83 -136
- package/lib/SVF-FE/SymbolTableBuilder.cpp +81 -23
- package/lib/Util/Options.cpp +6 -0
- package/lib/Util/TypeBasedHeapCloning.cpp +1 -1
- package/lib/WPA/AndersenStat.cpp +1 -1
- package/package.json +1 -1
|
@@ -269,19 +269,23 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
269
269
|
for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V);
|
|
270
270
|
gi != ge; ++gi)
|
|
271
271
|
{
|
|
272
|
-
|
|
272
|
+
const Type* gepTy = *gi;
|
|
273
|
+
const Value* offsetVal = gi.getOperand();
|
|
274
|
+
ls.addOffsetValue(offsetVal, gepTy);
|
|
273
275
|
|
|
274
276
|
//The int value of the current index operand
|
|
275
|
-
ConstantInt *op = SVFUtil::dyn_cast<ConstantInt>(
|
|
277
|
+
const ConstantInt *op = SVFUtil::dyn_cast<ConstantInt>(offsetVal);
|
|
276
278
|
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
// if Options::ModelConsts is disabled. We will treat whole array as one,
|
|
280
|
+
// but we can distinguish different field of an array of struct, e.g. s[1].f1 is differet from s[0].f2
|
|
281
|
+
if(SVFUtil::isa<ArrayType>(gepTy)){
|
|
282
|
+
if(!op)
|
|
283
|
+
continue;
|
|
284
|
+
s64_t idx = op->getSExtValue();
|
|
285
|
+
u32_t offset = SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(gepTy, idx);
|
|
286
|
+
ls.setFldIdx(ls.accumulateConstantFieldIdx() + offset);
|
|
287
|
+
}
|
|
288
|
+
else if (const StructType *ST = SVFUtil::dyn_cast<StructType>(gepTy))
|
|
285
289
|
{
|
|
286
290
|
// If the first operand is a non-constant, it is likely an array access
|
|
287
291
|
// (e.g., %ptr = getelementptr struct_A, %struct_A* %1, i64 %idx)
|
|
@@ -291,29 +295,21 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
291
295
|
assert(op && "non-const index in an operand in GEP");
|
|
292
296
|
//The actual index
|
|
293
297
|
s64_t idx = op->getSExtValue();
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
{
|
|
297
|
-
outs() << "!! Struct index out of bounds" << idx << "\n";
|
|
298
|
-
assert(0);
|
|
299
|
-
}
|
|
300
|
-
// add the translated offset
|
|
301
|
-
ls.setFldIdx(ls.accumulateConstantFieldIdx() + so[idx]);
|
|
298
|
+
u32_t offset = SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(ST, idx);
|
|
299
|
+
ls.setFldIdx(ls.accumulateConstantFieldIdx() + offset);
|
|
302
300
|
}
|
|
303
|
-
|
|
304
|
-
if ((*gi)->isSingleValueType())
|
|
301
|
+
else if (gepTy->isSingleValueType())
|
|
305
302
|
{
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
303
|
+
// Handle non-constant index
|
|
304
|
+
// Given a gep edge p = q + idx, where idx is non-constant
|
|
305
|
+
if(!op)
|
|
309
306
|
return false;
|
|
310
|
-
}
|
|
311
307
|
// The actual index
|
|
312
308
|
s64_t idx = op->getSExtValue();
|
|
313
309
|
|
|
314
310
|
// infer the field offset based on the byte offset
|
|
315
311
|
u32_t fieldOffset = inferFieldIdxFromByteOffset(gepOp, dataLayout, ls, idx);
|
|
316
|
-
ls.setFldIdx(fieldOffset);
|
|
312
|
+
ls.setFldIdx(ls.accumulateConstantFieldIdx() + fieldOffset);
|
|
317
313
|
}
|
|
318
314
|
}
|
|
319
315
|
return true;
|
|
@@ -463,7 +459,7 @@ NodeID SVFIRBuilder::getGlobalVarField(const GlobalVariable *gvar, u32_t offset)
|
|
|
463
459
|
const Type *gvartype = gvar->getType();
|
|
464
460
|
while (const PointerType *ptype = SVFUtil::dyn_cast<PointerType>(gvartype))
|
|
465
461
|
gvartype = ptype->getElementType();
|
|
466
|
-
return getGepValVar(gvar, LocationSet(offset), gvartype
|
|
462
|
+
return getGepValVar(gvar, LocationSet(offset), gvartype);
|
|
467
463
|
}
|
|
468
464
|
}
|
|
469
465
|
|
|
@@ -521,28 +517,30 @@ void SVFIRBuilder::InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
|
521
517
|
addCopyEdge(pag->getNullPtr(), src);
|
|
522
518
|
}
|
|
523
519
|
}
|
|
524
|
-
else if (SVFUtil::isa<ConstantArray>(C))
|
|
525
|
-
{
|
|
526
|
-
if (cppUtil::isValVtbl(gvar) == false)
|
|
527
|
-
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
528
|
-
InitialGlobal(gvar, SVFUtil::cast<Constant>(C->getOperand(i)), offset);
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
else if (SVFUtil::isa<ConstantStruct>(C))
|
|
520
|
+
else if (SVFUtil::isa<ConstantArray>(C) || SVFUtil::isa<ConstantStruct>(C))
|
|
532
521
|
{
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(sty);
|
|
536
|
-
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
537
|
-
{
|
|
538
|
-
u32_t off = offsetvect[i];
|
|
522
|
+
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++){
|
|
523
|
+
u32_t off = SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(C->getType(), i);
|
|
539
524
|
InitialGlobal(gvar, SVFUtil::cast<Constant>(C->getOperand(i)), offset + off);
|
|
540
525
|
}
|
|
541
|
-
|
|
542
526
|
}
|
|
543
|
-
else
|
|
527
|
+
else if(ConstantData* data = SVFUtil::dyn_cast<ConstantData>(C))
|
|
544
528
|
{
|
|
545
|
-
|
|
529
|
+
if(Options::ModelConsts){
|
|
530
|
+
if(ConstantDataSequential* seq = SVFUtil::dyn_cast<ConstantDataSequential>(data)){
|
|
531
|
+
for(u32_t i = 0; i < seq->getNumElements(); i++){
|
|
532
|
+
u32_t off = SymbolTableInfo::SymbolInfo()->getFlattenedElemIdx(C->getType(), i);
|
|
533
|
+
Constant* ct = seq->getElementAsConstant(i);
|
|
534
|
+
InitialGlobal(gvar, ct, offset + off);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
else{
|
|
538
|
+
InitialGlobal(gvar, data, offset);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else{
|
|
543
|
+
//TODO:assert(SVFUtil::isa<ConstantVector>(C),"what else do we have");
|
|
546
544
|
}
|
|
547
545
|
}
|
|
548
546
|
|
|
@@ -709,7 +707,7 @@ void SVFIRBuilder::visitCastInst(CastInst &inst)
|
|
|
709
707
|
}
|
|
710
708
|
else
|
|
711
709
|
{
|
|
712
|
-
Value * opnd = inst.getOperand(0);
|
|
710
|
+
const Value * opnd = inst.getOperand(0);
|
|
713
711
|
if (!SVFUtil::isa<PointerType>(opnd->getType()))
|
|
714
712
|
opnd = stripAllCasts(opnd);
|
|
715
713
|
|
|
@@ -730,7 +728,7 @@ void SVFIRBuilder::visitBinaryOperator(BinaryOperator &inst)
|
|
|
730
728
|
Value* op2 = inst.getOperand(1);
|
|
731
729
|
NodeID op2Node = getValueNode(op2);
|
|
732
730
|
u32_t opcode = inst.getOpcode();
|
|
733
|
-
|
|
731
|
+
addBinaryOPEdge(op1Node, op2Node, dst, opcode);
|
|
734
732
|
}
|
|
735
733
|
|
|
736
734
|
/*!
|
|
@@ -743,7 +741,7 @@ void SVFIRBuilder::visitUnaryOperator(UnaryOperator &inst)
|
|
|
743
741
|
Value* opnd = inst.getOperand(0);
|
|
744
742
|
NodeID src = getValueNode(opnd);
|
|
745
743
|
u32_t opcode = inst.getOpcode();
|
|
746
|
-
|
|
744
|
+
addUnaryOPEdge(src, dst, opcode);
|
|
747
745
|
}
|
|
748
746
|
|
|
749
747
|
/*!
|
|
@@ -758,7 +756,7 @@ void SVFIRBuilder::visitCmpInst(CmpInst &inst)
|
|
|
758
756
|
Value* op2 = inst.getOperand(1);
|
|
759
757
|
NodeID op2Node = getValueNode(op2);
|
|
760
758
|
u32_t predicate = inst.getPredicate();
|
|
761
|
-
|
|
759
|
+
addCmpEdge(op1Node, op2Node, dst, predicate);
|
|
762
760
|
}
|
|
763
761
|
|
|
764
762
|
|
|
@@ -897,7 +895,7 @@ void SVFIRBuilder::visitBranchInst(BranchInst &inst){
|
|
|
897
895
|
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(succInst);
|
|
898
896
|
successors.push_back(std::make_pair(icfgNode, 1-i));
|
|
899
897
|
}
|
|
900
|
-
|
|
898
|
+
addBranchStmt(brinst, cond,successors);
|
|
901
899
|
}
|
|
902
900
|
|
|
903
901
|
void SVFIRBuilder::visitSwitchInst(SwitchInst &inst){
|
|
@@ -914,7 +912,7 @@ void SVFIRBuilder::visitSwitchInst(SwitchInst &inst){
|
|
|
914
912
|
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(succInst);
|
|
915
913
|
successors.push_back(std::make_pair(icfgNode,val));
|
|
916
914
|
}
|
|
917
|
-
|
|
915
|
+
addBranchStmt(brinst, cond,successors);
|
|
918
916
|
}
|
|
919
917
|
|
|
920
918
|
/// %ap = alloca %struct.va_list
|
|
@@ -1012,57 +1010,34 @@ void SVFIRBuilder::handleDirectCall(CallSite cs, const SVFFunction *F)
|
|
|
1012
1010
|
}
|
|
1013
1011
|
}
|
|
1014
1012
|
|
|
1015
|
-
|
|
1016
1013
|
/*!
|
|
1017
1014
|
* Find the base type and the max possible offset of an object pointed to by (V).
|
|
1018
1015
|
*/
|
|
1019
|
-
const Type *SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields)
|
|
1016
|
+
const Type *SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields, const Value* szValue)
|
|
1020
1017
|
{
|
|
1021
1018
|
assert(V);
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
if (const User *U = SVFUtil::dyn_cast<User>(V))
|
|
1027
|
-
{
|
|
1028
|
-
u32_t msz = 1; //the max size seen so far
|
|
1029
|
-
// In case of BitCast, try the target type itself
|
|
1030
|
-
if (SVFUtil::isa<BitCastInst>(V))
|
|
1031
|
-
{
|
|
1032
|
-
u32_t sz = getFields(fields, T, msz);
|
|
1033
|
-
if (msz < sz)
|
|
1034
|
-
{
|
|
1035
|
-
msz = sz;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
// Try the types of all operands
|
|
1039
|
-
for (User::const_op_iterator it = U->op_begin(), ie = U->op_end();
|
|
1040
|
-
it != ie; ++it)
|
|
1041
|
-
{
|
|
1042
|
-
const Type *operandtype = it->get()->getType();
|
|
1043
|
-
|
|
1044
|
-
u32_t sz = getFields(fields, operandtype, msz);
|
|
1045
|
-
if (msz < sz)
|
|
1046
|
-
{
|
|
1047
|
-
msz = sz;
|
|
1048
|
-
T = operandtype;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
// If V is a CE, the actual pointer type is its operand.
|
|
1053
|
-
else if (const ConstantExpr *E = SVFUtil::dyn_cast<ConstantExpr>(V))
|
|
1054
|
-
{
|
|
1055
|
-
T = E->getOperand(0)->getType();
|
|
1056
|
-
getFields(fields, T, 0);
|
|
1057
|
-
}
|
|
1058
|
-
// Handle Argument case
|
|
1059
|
-
else if (SVFUtil::isa<Argument>(V))
|
|
1060
|
-
{
|
|
1061
|
-
getFields(fields, T, 0);
|
|
1062
|
-
}
|
|
1019
|
+
const Value * value = stripAllCasts(V);
|
|
1020
|
+
assert(value && "null ptr?");
|
|
1021
|
+
if(const GetElementPtrInst* gep = SVFUtil::dyn_cast<GetElementPtrInst>(value))
|
|
1022
|
+
value = gep->getPointerOperand();
|
|
1063
1023
|
|
|
1024
|
+
const Type *T = value->getType();
|
|
1064
1025
|
while (const PointerType *ptype = SVFUtil::dyn_cast<PointerType>(T))
|
|
1065
1026
|
T = ptype->getElementType();
|
|
1027
|
+
|
|
1028
|
+
u32_t numOfElems = SymbolTableInfo::SymbolInfo()->getNumOfFlattenElements(T);
|
|
1029
|
+
/// use user-specified size for this copy operation if the size is a constaint int
|
|
1030
|
+
if(szValue && SVFUtil::isa<ConstantInt>(szValue))
|
|
1031
|
+
numOfElems = SVFUtil::cast<ConstantInt>(szValue)->getSExtValue();
|
|
1032
|
+
|
|
1033
|
+
LLVMContext& context = LLVMModuleSet::getLLVMModuleSet()->getContext();
|
|
1034
|
+
for(u32_t ei = 0; ei < numOfElems; ei++){
|
|
1035
|
+
LocationSet ls(ei);
|
|
1036
|
+
// make a ConstantInt and create char for the content type due to byte-wise copy
|
|
1037
|
+
const ConstantInt* offset = ConstantInt::get(context, llvm::APInt(32, ei));
|
|
1038
|
+
ls.addOffsetValue(offset, nullptr);
|
|
1039
|
+
fields.push_back(ls);
|
|
1040
|
+
}
|
|
1066
1041
|
return T;
|
|
1067
1042
|
}
|
|
1068
1043
|
|
|
@@ -1070,7 +1045,7 @@ const Type *SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value *V, std::vec
|
|
|
1070
1045
|
* Add the load/store constraints and temp. nodes for the complex constraint
|
|
1071
1046
|
* *D = *S (where D/S may point to structs).
|
|
1072
1047
|
*/
|
|
1073
|
-
void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S,
|
|
1048
|
+
void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S, const Value* szValue)
|
|
1074
1049
|
{
|
|
1075
1050
|
assert(D && S);
|
|
1076
1051
|
NodeID vnD= getValueNode(D), vnS= getValueNode(S);
|
|
@@ -1082,18 +1057,16 @@ void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S, u32_t sz)
|
|
|
1082
1057
|
//Get the max possible size of the copy, unless it was provided.
|
|
1083
1058
|
std::vector<LocationSet> srcFields;
|
|
1084
1059
|
std::vector<LocationSet> dstFields;
|
|
1085
|
-
const Type *stype = getBaseTypeAndFlattenedFields(S, srcFields);
|
|
1086
|
-
const Type *dtype = getBaseTypeAndFlattenedFields(D, dstFields);
|
|
1060
|
+
const Type *stype = getBaseTypeAndFlattenedFields(S, srcFields, szValue);
|
|
1061
|
+
const Type *dtype = getBaseTypeAndFlattenedFields(D, dstFields, szValue);
|
|
1087
1062
|
if(srcFields.size() > dstFields.size())
|
|
1088
1063
|
fields = dstFields;
|
|
1089
1064
|
else
|
|
1090
1065
|
fields = srcFields;
|
|
1091
1066
|
|
|
1092
1067
|
/// If sz is 0, we will add edges for all fields.
|
|
1093
|
-
|
|
1094
|
-
sz = fields.size();
|
|
1068
|
+
u32_t sz = fields.size();
|
|
1095
1069
|
|
|
1096
|
-
assert(fields.size() >= sz && "the number of flattened fields is smaller than size");
|
|
1097
1070
|
if (fields.size() == 1 && (isConstantData(D) || isConstantData(S))) {
|
|
1098
1071
|
NodeID dummy = pag->addDummyValNode();
|
|
1099
1072
|
addLoadEdge(vnD,dummy);
|
|
@@ -1104,8 +1077,8 @@ void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S, u32_t sz)
|
|
|
1104
1077
|
//For each field (i), add (Ti = *S + i) and (*D + i = Ti).
|
|
1105
1078
|
for (u32_t index = 0; index < sz; index++)
|
|
1106
1079
|
{
|
|
1107
|
-
NodeID dField = getGepValVar(D,fields[index],dtype
|
|
1108
|
-
NodeID sField = getGepValVar(S,fields[index],stype
|
|
1080
|
+
NodeID dField = getGepValVar(D,fields[index],dtype);
|
|
1081
|
+
NodeID sField = getGepValVar(S,fields[index],stype);
|
|
1109
1082
|
NodeID dummy = pag->addDummyValNode();
|
|
1110
1083
|
addLoadEdge(sField,dummy);
|
|
1111
1084
|
addStoreEdge(dummy,dField);
|
|
@@ -1138,7 +1111,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1138
1111
|
{
|
|
1139
1112
|
NodeID vnArg = getValueNode(arg);
|
|
1140
1113
|
NodeID dummy = pag->addDummyValNode();
|
|
1141
|
-
NodeID obj = pag->addDummyObjNode();
|
|
1114
|
+
NodeID obj = pag->addDummyObjNode(arg->getType());
|
|
1142
1115
|
if (vnArg && dummy && obj)
|
|
1143
1116
|
{
|
|
1144
1117
|
addAddrEdge(obj, dummy);
|
|
@@ -1220,7 +1193,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1220
1193
|
}
|
|
1221
1194
|
case ExtAPI::EFT_L_A0__A0R_A1R:
|
|
1222
1195
|
{
|
|
1223
|
-
addComplexConsForExt(cs.getArgument(0), cs.getArgument(1));
|
|
1196
|
+
addComplexConsForExt(cs.getArgument(0), cs.getArgument(1), cs.getArgument(2));
|
|
1224
1197
|
//memcpy returns the dest.
|
|
1225
1198
|
if(SVFUtil::isa<PointerType>(inst->getType()))
|
|
1226
1199
|
{
|
|
@@ -1229,7 +1202,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1229
1202
|
break;
|
|
1230
1203
|
}
|
|
1231
1204
|
case ExtAPI::EFT_A1R_A0R:
|
|
1232
|
-
addComplexConsForExt(cs.getArgument(1), cs.getArgument(0));
|
|
1205
|
+
addComplexConsForExt(cs.getArgument(1), cs.getArgument(0), cs.getArgument(2));
|
|
1233
1206
|
break;
|
|
1234
1207
|
case ExtAPI::EFT_L_A1__FunPtr:
|
|
1235
1208
|
{
|
|
@@ -1249,7 +1222,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1249
1222
|
}
|
|
1250
1223
|
case ExtAPI::EFT_A3R_A1R_NS:
|
|
1251
1224
|
//These func. are never used to copy structs, so the size is 1.
|
|
1252
|
-
addComplexConsForExt(cs.getArgument(3), cs.getArgument(1),
|
|
1225
|
+
addComplexConsForExt(cs.getArgument(3), cs.getArgument(1), nullptr);
|
|
1253
1226
|
break;
|
|
1254
1227
|
case ExtAPI::EFT_A1R_A0:
|
|
1255
1228
|
{
|
|
@@ -1352,14 +1325,14 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1352
1325
|
|
|
1353
1326
|
// We get all flattened fields of base
|
|
1354
1327
|
vector<LocationSet> fields;
|
|
1355
|
-
const Type *type = getBaseTypeAndFlattenedFields(vArg3, fields);
|
|
1328
|
+
const Type *type = getBaseTypeAndFlattenedFields(vArg3, fields, nullptr);
|
|
1356
1329
|
assert(fields.size() >= 4 && "_Rb_tree_node_base should have at least 4 fields.\n");
|
|
1357
1330
|
|
|
1358
1331
|
// We summarize the side effects: arg3->parent = arg1, arg3->left = arg1, arg3->right = arg1
|
|
1359
1332
|
// Note that arg0 is aligned with "offset".
|
|
1360
1333
|
for (int i = offset + 1; i <= offset + 3; ++i)
|
|
1361
1334
|
{
|
|
1362
|
-
NodeID vnD = getGepValVar(vArg3, fields[i], type
|
|
1335
|
+
NodeID vnD = getGepValVar(vArg3, fields[i], type);
|
|
1363
1336
|
NodeID vnS = getValueNode(vArg1);
|
|
1364
1337
|
if(vnD && vnS)
|
|
1365
1338
|
addStoreEdge(vnS,vnD);
|
|
@@ -1376,14 +1349,14 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1376
1349
|
|
|
1377
1350
|
// We get all fields
|
|
1378
1351
|
vector<LocationSet> fields;
|
|
1379
|
-
const Type *type = getBaseTypeAndFlattenedFields(vArg,fields);
|
|
1352
|
+
const Type *type = getBaseTypeAndFlattenedFields(vArg,fields,nullptr);
|
|
1380
1353
|
assert(fields.size() >= 4 && "_Rb_tree_node_base should have at least 4 fields.\n");
|
|
1381
1354
|
|
|
1382
1355
|
// We summarize the side effects: ret = arg->parent, ret = arg->left, ret = arg->right
|
|
1383
1356
|
// Note that arg0 is aligned with "offset".
|
|
1384
1357
|
for (int i = offset + 1; i <= offset + 3; ++i)
|
|
1385
1358
|
{
|
|
1386
|
-
NodeID vnS = getGepValVar(vArg, fields[i], type
|
|
1359
|
+
NodeID vnS = getGepValVar(vArg, fields[i], type);
|
|
1387
1360
|
if(vnD && vnS)
|
|
1388
1361
|
addStoreEdge(vnS,vnD);
|
|
1389
1362
|
}
|
|
@@ -1567,7 +1540,7 @@ void SVFIRBuilder::sanityCheck()
|
|
|
1567
1540
|
* Add a temp field value node according to base value and offset
|
|
1568
1541
|
* this node is after the initial node method, it is out of scope of symInfo table
|
|
1569
1542
|
*/
|
|
1570
|
-
NodeID SVFIRBuilder::getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType
|
|
1543
|
+
NodeID SVFIRBuilder::getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType)
|
|
1571
1544
|
{
|
|
1572
1545
|
NodeID base = pag->getBaseValVar(getValueNode(val));
|
|
1573
1546
|
NodeID gepval = pag->getGepValVar(curVal, base, ls);
|
|
@@ -1583,15 +1556,13 @@ NodeID SVFIRBuilder::getGepValVar(const Value* val, const LocationSet& ls, const
|
|
|
1583
1556
|
* 2. GlobalVariable
|
|
1584
1557
|
*/
|
|
1585
1558
|
assert((SVFUtil::isa<Instruction>(curVal) || SVFUtil::isa<GlobalVariable>(curVal)) && "curVal not an instruction or a globalvariable?");
|
|
1586
|
-
const std::vector<FlattenedFieldInfo> &fieldinfo = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(baseType);
|
|
1587
|
-
const Type *type = fieldinfo[fieldidx].getFlattenElemTy();
|
|
1588
1559
|
|
|
1589
1560
|
// We assume every GepValNode and its GepEdge to the baseNode are unique across the whole program
|
|
1590
1561
|
// We preserve the current BB information to restore it after creating the gepNode
|
|
1591
1562
|
const Value* cval = getCurrentValue();
|
|
1592
1563
|
const BasicBlock* cbb = getCurrentBB();
|
|
1593
1564
|
setCurrentLocation(curVal, nullptr);
|
|
1594
|
-
NodeID gepNode= pag->addGepValNode(curVal, val,ls, NodeIDAllocator::get()->allocateValueId(),
|
|
1565
|
+
NodeID gepNode= pag->addGepValNode(curVal, val,ls, NodeIDAllocator::get()->allocateValueId(),baseType);
|
|
1595
1566
|
addGepEdge(base, gepNode, ls, true);
|
|
1596
1567
|
setCurrentLocation(cval, cbb);
|
|
1597
1568
|
return gepNode;
|
|
@@ -1701,30 +1672,6 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1701
1672
|
}
|
|
1702
1673
|
}
|
|
1703
1674
|
|
|
1704
|
-
|
|
1705
|
-
/*!
|
|
1706
|
-
* Replace fields with flatten fields of T if the number of its fields is larger than msz.
|
|
1707
|
-
*/
|
|
1708
|
-
u32_t SVFIRBuilder::getFields(std::vector<LocationSet>& fields, const Type* T, u32_t msz)
|
|
1709
|
-
{
|
|
1710
|
-
if (!SVFUtil::isa<PointerType>(T))
|
|
1711
|
-
return 0;
|
|
1712
|
-
|
|
1713
|
-
T = T->getContainedType(0);
|
|
1714
|
-
const std::vector<FlattenedFieldInfo>& stVec = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(T);
|
|
1715
|
-
u32_t sz = stVec.size();
|
|
1716
|
-
if (msz < sz)
|
|
1717
|
-
{
|
|
1718
|
-
/// Replace fields with T's flatten fields.
|
|
1719
|
-
fields.clear();
|
|
1720
|
-
for(std::vector<FlattenedFieldInfo>::const_iterator it = stVec.begin(), eit = stVec.end(); it!=eit; ++it)
|
|
1721
|
-
fields.push_back(LocationSet(*it));
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
return sz;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
1675
|
void SVFIRBuilder::updateCallGraph(PTACallGraph* callgraph){
|
|
1729
1676
|
PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin();
|
|
1730
1677
|
PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end();
|
|
@@ -412,15 +412,14 @@ void SymbolTableBuilder::handleGlobalCE(const GlobalVariable *G)
|
|
|
412
412
|
|
|
413
413
|
if (G->hasInitializer())
|
|
414
414
|
{
|
|
415
|
-
handleGlobalInitializerCE(G->getInitializer()
|
|
415
|
+
handleGlobalInitializerCE(G->getInitializer());
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
/*!
|
|
420
420
|
* Handle global variable initialization
|
|
421
421
|
*/
|
|
422
|
-
void SymbolTableBuilder::handleGlobalInitializerCE(const Constant *C
|
|
423
|
-
u32_t offset)
|
|
422
|
+
void SymbolTableBuilder::handleGlobalInitializerCE(const Constant *C)
|
|
424
423
|
{
|
|
425
424
|
|
|
426
425
|
if (C->getType()->isSingleValueType())
|
|
@@ -438,21 +437,33 @@ void SymbolTableBuilder::handleGlobalInitializerCE(const Constant *C,
|
|
|
438
437
|
{
|
|
439
438
|
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
440
439
|
{
|
|
441
|
-
handleGlobalInitializerCE(SVFUtil::cast<Constant>(C->getOperand(i))
|
|
440
|
+
handleGlobalInitializerCE(SVFUtil::cast<Constant>(C->getOperand(i)));
|
|
442
441
|
}
|
|
443
442
|
}
|
|
444
443
|
else if (SVFUtil::isa<ConstantStruct>(C))
|
|
445
444
|
{
|
|
446
|
-
const StructType *sty = SVFUtil::cast<StructType>(C->getType());
|
|
447
|
-
const std::vector<u32_t>& offsetvect =
|
|
448
|
-
SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(sty);
|
|
449
445
|
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
450
446
|
{
|
|
451
|
-
|
|
452
|
-
handleGlobalInitializerCE(SVFUtil::cast<Constant>(C->getOperand(i)),
|
|
453
|
-
offset + off);
|
|
447
|
+
handleGlobalInitializerCE(SVFUtil::cast<Constant>(C->getOperand(i)));
|
|
454
448
|
}
|
|
455
449
|
}
|
|
450
|
+
else if(const ConstantData* data = SVFUtil::dyn_cast<ConstantData>(C))
|
|
451
|
+
{
|
|
452
|
+
if(Options::ModelConsts){
|
|
453
|
+
if(const ConstantDataSequential* seq = SVFUtil::dyn_cast<ConstantDataSequential>(data)){
|
|
454
|
+
for(u32_t i = 0; i < seq->getNumElements(); i++){
|
|
455
|
+
const Constant* ct = seq->getElementAsConstant(i);
|
|
456
|
+
handleGlobalInitializerCE(ct);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
else{
|
|
460
|
+
handleGlobalInitializerCE(data);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else{
|
|
465
|
+
//TODO:assert(SVFUtil::isa<ConstantVector>(C),"what else do we have");
|
|
466
|
+
}
|
|
456
467
|
}
|
|
457
468
|
|
|
458
469
|
/*
|
|
@@ -475,7 +486,7 @@ ObjTypeInfo* SymbolTableBuilder::createObjTypeInfo(const Value *val)
|
|
|
475
486
|
if (refTy)
|
|
476
487
|
{
|
|
477
488
|
Type *objTy = refTy->getElementType();
|
|
478
|
-
ObjTypeInfo* typeInfo = new ObjTypeInfo(
|
|
489
|
+
ObjTypeInfo* typeInfo = new ObjTypeInfo(objTy, Options::MaxFieldLimit);
|
|
479
490
|
initTypeInfo(typeInfo,val);
|
|
480
491
|
return typeInfo;
|
|
481
492
|
}
|
|
@@ -485,7 +496,7 @@ ObjTypeInfo* SymbolTableBuilder::createObjTypeInfo(const Value *val)
|
|
|
485
496
|
writeWrnMsg(val->getName().str());
|
|
486
497
|
writeWrnMsg("(" + getSourceLoc(val) + ")");
|
|
487
498
|
if(symInfo->isConstantObjSym(val)){
|
|
488
|
-
ObjTypeInfo* typeInfo = new ObjTypeInfo(val
|
|
499
|
+
ObjTypeInfo* typeInfo = new ObjTypeInfo(val->getType(), 0);
|
|
489
500
|
initTypeInfo(typeInfo,val);
|
|
490
501
|
return typeInfo;
|
|
491
502
|
}
|
|
@@ -496,15 +507,14 @@ ObjTypeInfo* SymbolTableBuilder::createObjTypeInfo(const Value *val)
|
|
|
496
507
|
}
|
|
497
508
|
}
|
|
498
509
|
|
|
499
|
-
|
|
500
510
|
/*!
|
|
501
511
|
* Analyse types of all flattened fields of this object
|
|
502
512
|
*/
|
|
503
|
-
void SymbolTableBuilder::
|
|
513
|
+
void SymbolTableBuilder::analyzeObjType(ObjTypeInfo* typeinfo, const Value* val)
|
|
504
514
|
{
|
|
505
515
|
|
|
506
516
|
const PointerType * refty = SVFUtil::dyn_cast<PointerType>(val->getType());
|
|
507
|
-
assert(
|
|
517
|
+
assert(refty && "this value should be a pointer type!");
|
|
508
518
|
Type* elemTy = refty->getElementType();
|
|
509
519
|
bool isPtrObj = false;
|
|
510
520
|
// Find the inter nested array element
|
|
@@ -515,9 +525,7 @@ void SymbolTableBuilder::analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const
|
|
|
515
525
|
isPtrObj = true;
|
|
516
526
|
if(SVFUtil::isa<GlobalVariable>(val) && SVFUtil::cast<GlobalVariable>(val)->hasInitializer()
|
|
517
527
|
&& SVFUtil::isa<ConstantArray>(SVFUtil::cast<GlobalVariable>(val)->getInitializer()))
|
|
518
|
-
{
|
|
519
528
|
typeinfo->setFlag(ObjTypeInfo::CONST_ARRAY_OBJ);
|
|
520
|
-
}
|
|
521
529
|
else
|
|
522
530
|
typeinfo->setFlag(ObjTypeInfo::VAR_ARRAY_OBJ);
|
|
523
531
|
}
|
|
@@ -545,6 +553,56 @@ void SymbolTableBuilder::analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const
|
|
|
545
553
|
typeinfo->setFlag(ObjTypeInfo::HASPTR_OBJ);
|
|
546
554
|
}
|
|
547
555
|
|
|
556
|
+
/*!
|
|
557
|
+
* Analyse types of heap and static objects
|
|
558
|
+
*/
|
|
559
|
+
void SymbolTableBuilder::analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val)
|
|
560
|
+
{
|
|
561
|
+
if(const Value* castUse = getUniqueUseViaCastInst(val)){
|
|
562
|
+
typeinfo->setFlag(ObjTypeInfo::HEAP_OBJ);
|
|
563
|
+
typeinfo->resetTypeForHeapStaticObj(castUse->getType());
|
|
564
|
+
analyzeObjType(typeinfo,castUse);
|
|
565
|
+
}
|
|
566
|
+
else{
|
|
567
|
+
typeinfo->setFlag(ObjTypeInfo::HEAP_OBJ);
|
|
568
|
+
typeinfo->setFlag(ObjTypeInfo::HASPTR_OBJ);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/*!
|
|
573
|
+
* Analyse types of heap and static objects
|
|
574
|
+
*/
|
|
575
|
+
void SymbolTableBuilder::analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val)
|
|
576
|
+
{
|
|
577
|
+
if(const Value* castUse = getUniqueUseViaCastInst(val)){
|
|
578
|
+
typeinfo->setFlag(ObjTypeInfo::STATIC_OBJ);
|
|
579
|
+
typeinfo->resetTypeForHeapStaticObj(castUse->getType());
|
|
580
|
+
analyzeObjType(typeinfo,castUse);
|
|
581
|
+
}
|
|
582
|
+
else{
|
|
583
|
+
typeinfo->setFlag(ObjTypeInfo::HEAP_OBJ);
|
|
584
|
+
typeinfo->setFlag(ObjTypeInfo::HASPTR_OBJ);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/*
|
|
589
|
+
* Get the first dominated cast instruction for heap allocations since they typically come from void* (i8*)
|
|
590
|
+
* for example, %4 = call align 16 i8* @malloc(i64 10); %5 = bitcast i8* %4 to i32*
|
|
591
|
+
* return %5 whose type is i32* but not %4 whose type is i8*
|
|
592
|
+
*/
|
|
593
|
+
const Value* SymbolTableBuilder::getUniqueUseViaCastInst(const Value* val){
|
|
594
|
+
const PointerType * type = SVFUtil::dyn_cast<PointerType>(val->getType());
|
|
595
|
+
assert(type && "this value should be a pointer type!");
|
|
596
|
+
/// If type is void* (i8*) and val is only used at a bitcast instruction
|
|
597
|
+
if (IntegerType *IT = SVFUtil::dyn_cast<IntegerType>(type->getPointerElementType())){
|
|
598
|
+
if (IT->getBitWidth() == 8 && val->getNumUses()==1){
|
|
599
|
+
const Use *u = &*val->use_begin();
|
|
600
|
+
return SVFUtil::dyn_cast<BitCastInst>(u->getUser());
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return nullptr;
|
|
604
|
+
}
|
|
605
|
+
|
|
548
606
|
/*!
|
|
549
607
|
* Initialize the type info of an object
|
|
550
608
|
*/
|
|
@@ -555,13 +613,13 @@ void SymbolTableBuilder::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val){
|
|
|
555
613
|
if (SVFUtil::isa<Function>(val))
|
|
556
614
|
{
|
|
557
615
|
typeinfo->setFlag(ObjTypeInfo::FUNCTION_OBJ);
|
|
558
|
-
|
|
616
|
+
analyzeObjType(typeinfo,val);
|
|
559
617
|
objSize = getObjSize(val);
|
|
560
618
|
}
|
|
561
619
|
else if(SVFUtil::isa<AllocaInst>(val))
|
|
562
620
|
{
|
|
563
621
|
typeinfo->setFlag(ObjTypeInfo::STACK_OBJ);
|
|
564
|
-
|
|
622
|
+
analyzeObjType(typeinfo,val);
|
|
565
623
|
objSize = getObjSize(val);
|
|
566
624
|
}
|
|
567
625
|
else if(SVFUtil::isa<GlobalVariable>(val))
|
|
@@ -569,24 +627,24 @@ void SymbolTableBuilder::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val){
|
|
|
569
627
|
typeinfo->setFlag(ObjTypeInfo::GLOBVAR_OBJ);
|
|
570
628
|
if(SymbolTableInfo::SymbolInfo()->isConstantObjSym(val))
|
|
571
629
|
typeinfo->setFlag(ObjTypeInfo::CONST_GLOBAL_OBJ);
|
|
572
|
-
|
|
630
|
+
analyzeObjType(typeinfo,val);
|
|
573
631
|
objSize = getObjSize(val);
|
|
574
632
|
}
|
|
575
633
|
else if (SVFUtil::isa<Instruction>(val) && isHeapAllocExtCall(SVFUtil::cast<Instruction>(val)))
|
|
576
634
|
{
|
|
577
|
-
|
|
635
|
+
analyzeHeapObjType(typeinfo,val);
|
|
578
636
|
// Heap object, label its field as infinite here
|
|
579
637
|
objSize = -1;
|
|
580
638
|
}
|
|
581
639
|
else if (SVFUtil::isa<Instruction>(val) && isStaticExtCall(SVFUtil::cast<Instruction>(val)))
|
|
582
640
|
{
|
|
583
|
-
|
|
641
|
+
analyzeStaticObjType(typeinfo,val);
|
|
584
642
|
// static object allocated before main, label its field as infinite here
|
|
585
643
|
objSize = -1;
|
|
586
644
|
}
|
|
587
645
|
else if(ArgInProgEntryFunction(val))
|
|
588
646
|
{
|
|
589
|
-
|
|
647
|
+
analyzeStaticObjType(typeinfo,val);
|
|
590
648
|
// user input data, label its field as infinite here
|
|
591
649
|
objSize = -1;
|
|
592
650
|
}
|
package/lib/Util/Options.cpp
CHANGED
|
@@ -636,6 +636,12 @@ namespace SVF
|
|
|
636
636
|
llvm::cl::desc("Modeling individual constant objects")
|
|
637
637
|
);
|
|
638
638
|
|
|
639
|
+
const llvm::cl::opt<bool> Options::ModelArrays(
|
|
640
|
+
"model-arrays",
|
|
641
|
+
llvm::cl::init(false),
|
|
642
|
+
llvm::cl::desc("Modeling Gep offsets for array accesses")
|
|
643
|
+
);
|
|
644
|
+
|
|
639
645
|
const llvm::cl::opt<bool> Options::SymTabPrint(
|
|
640
646
|
"print-symbol-table", llvm::cl::init(false),
|
|
641
647
|
llvm::cl::desc("Print Symbol Table to command line")
|
|
@@ -259,7 +259,7 @@ const NodeBS TypeBasedHeapCloning::getGepObjClones(NodeID base, unsigned offset)
|
|
|
259
259
|
|
|
260
260
|
setType(newGep, newGepType);
|
|
261
261
|
// We call the object created in the non-TBHC analysis the original object.
|
|
262
|
-
setOriginalObj(newGep, ppag->getGepObjVar(baseNode->
|
|
262
|
+
setOriginalObj(newGep, ppag->getGepObjVar(baseNode->getId(), offset));
|
|
263
263
|
setAllocationSite(newGep, 0);
|
|
264
264
|
|
|
265
265
|
geps.set(newGep);
|
package/lib/WPA/AndersenStat.cpp
CHANGED
|
@@ -226,7 +226,7 @@ void AndersenStat::statNullPtr()
|
|
|
226
226
|
{
|
|
227
227
|
NodeID pagNodeId = iter->first;
|
|
228
228
|
PAGNode* pagNode = iter->second;
|
|
229
|
-
if (pagNode
|
|
229
|
+
if (SVFUtil::isa<ValVar>(pagNode) == false)
|
|
230
230
|
continue;
|
|
231
231
|
SVFStmt::SVFStmtSetTy& inComingStore = pagNode->getIncomingEdges(SVFStmt::Store);
|
|
232
232
|
SVFStmt::SVFStmtSetTy& outGoingLoad = pagNode->getOutgoingEdges(SVFStmt::Load);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.376",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|