├── pymetacg ├── .gitignore └── tests │ ├── .gitignore │ ├── requirements.txt │ ├── resources │ └── empty_cg.mcg │ └── CMakeLists.txt ├── .dockerignore ├── tools ├── cgdiff │ ├── test │ │ ├── integration │ │ │ ├── input │ │ │ │ ├── cgB_body.mcg │ │ │ │ ├── cgA_node_md.mcg │ │ │ │ ├── cgB_edge_md.mcg │ │ │ │ └── cgB_node_md.mcg │ │ │ ├── README.md │ │ │ └── groundtruthes │ │ │ │ ├── edge_missing_flag.json │ │ │ │ ├── body_different_flag.json │ │ │ │ ├── edge_different_flag.json │ │ │ │ ├── metadata_missing_flag.json │ │ │ │ ├── metadata_different_flag.json │ │ │ │ ├── global_md_different_flag.json │ │ │ │ └── global_md_different.json │ │ └── unit │ │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ ├── README.md │ └── include │ │ └── Diff.h ├── cgpatch │ └── test │ │ ├── integration │ │ ├── input │ │ │ ├── general │ │ │ │ ├── 042_a.cpp │ │ │ │ ├── 042_b.cpp │ │ │ │ └── 01_a.cpp │ │ │ └── mpi │ │ │ │ └── 001_a.cpp │ │ └── CMakeLists.txt │ │ ├── pass-tests │ │ ├── inst-test │ │ │ └── 04_inline.cpp │ │ └── vcall-detection-test │ │ │ ├── 09_lambda.cpp │ │ │ ├── 10_fake_vcall_2.cpp │ │ │ ├── 02_pointer_call.cpp │ │ │ ├── 08_call_in_dtor.cpp │ │ │ ├── 03_member_ptr.cpp │ │ │ ├── 04_ptr_to_vfun.cpp │ │ │ └── 05_ref_call.cpp │ │ └── CMakeLists.txt ├── cgcollector2 │ ├── test │ │ └── input │ │ │ ├── multiTU │ │ │ ├── 0070_b.cpp │ │ │ ├── 0043_a.cpp │ │ │ ├── 0044_b.cpp │ │ │ ├── 0042_a.cpp │ │ │ ├── 0053_a.cpp │ │ │ ├── 0043_b.cpp │ │ │ ├── 0044_a.cpp │ │ │ ├── 0214_b.cpp │ │ │ ├── 0050_a.cpp │ │ │ ├── 0060_b.cpp │ │ │ ├── 0042_b.cpp │ │ │ ├── 0050_b.cpp │ │ │ ├── 0050.h │ │ │ ├── 0071_b.cpp │ │ │ ├── 0070_a.cpp │ │ │ ├── 0053.h │ │ │ ├── 0214_a.cpp │ │ │ ├── 0241_b.cpp │ │ │ ├── 0071_a.cpp │ │ │ ├── 0240_a.cpp │ │ │ ├── 0053_b.cpp │ │ │ ├── 0240_b.cpp │ │ │ ├── 0072_b.cpp │ │ │ └── 0072_a.cpp │ │ │ ├── singleTU │ │ │ ├── 0001.cpp │ │ │ ├── 0233.cpp │ │ │ ├── 0022.cpp │ │ │ ├── 0222.cpp │ │ │ ├── 0226.cpp │ │ │ ├── 0002.cpp │ │ │ ├── 0003.cpp │ │ │ ├── 0066.cpp │ │ │ ├── 0215.cpp │ │ │ ├── 0227.cpp │ │ │ ├── 0005.cpp │ │ │ ├── 0004.cpp │ │ │ ├── 0063.cpp.disabled │ │ │ ├── 0013.cpp │ │ │ ├── 0014.cpp │ │ │ ├── 0063.gtmcg │ │ │ ├── 0223.cpp │ │ │ ├── 0221.cpp │ │ │ ├── 0224.cpp │ │ │ ├── 0228.cpp │ │ │ ├── 0234.cpp.disabled │ │ │ ├── 0235.cpp.disabled │ │ │ ├── 0230.cpp │ │ │ ├── 0232.cpp.disabled │ │ │ ├── 0237.cpp.disabled │ │ │ ├── 0065.cpp │ │ │ └── 0006.cpp_disabled │ │ │ ├── metaCollectors │ │ │ └── numStatements │ │ │ │ ├── 0041.cpp │ │ │ │ ├── 0023.cpp │ │ │ │ ├── 0024.cpp │ │ │ │ ├── 0025.cpp │ │ │ │ ├── 0026.cpp │ │ │ │ ├── 0027.cpp │ │ │ │ ├── 0028.cpp │ │ │ │ ├── 0038.cpp │ │ │ │ ├── 0037.cpp │ │ │ │ ├── 0039.cpp │ │ │ │ ├── 0029.cpp │ │ │ │ ├── 0034.cpp │ │ │ │ ├── 0035.cpp │ │ │ │ ├── 0030.cpp │ │ │ │ ├── 0042.cpp │ │ │ │ ├── 0031.cpp │ │ │ │ ├── 0036.cpp │ │ │ │ ├── 0040.cpp │ │ │ │ └── 0032.cpp │ │ │ ├── allCtorDtor │ │ │ ├── 0002.cpp │ │ │ ├── 0005.cpp │ │ │ ├── 0004.cpp │ │ │ ├── 0001.cpp │ │ │ ├── 0006.cpp │ │ │ ├── 0007.cpp │ │ │ ├── 0008.cpp │ │ │ └── 0003.cpp │ │ │ ├── functionPointers │ │ │ ├── 0216.cpp │ │ │ ├── 0208.cpp │ │ │ ├── 0201.cpp │ │ │ ├── 0211.cpp │ │ │ ├── 0202.cpp │ │ │ ├── 0214.cpp │ │ │ ├── 0100.cpp │ │ │ ├── 0210.cpp │ │ │ ├── 0212.cpp │ │ │ ├── 0101.cpp │ │ │ ├── 0049.cpp │ │ │ ├── 0103.cpp │ │ │ ├── 0205.cpp │ │ │ ├── 0213.cpp │ │ │ ├── 0102.cpp │ │ │ ├── 0204.cpp │ │ │ ├── 0206.cpp │ │ │ ├── 0115.cpp │ │ │ ├── 0217.cpp │ │ │ ├── 0048.cpp │ │ │ ├── 0203.cpp │ │ │ ├── 0051.cpp │ │ │ ├── 0047.cpp │ │ │ ├── 0046.cpp │ │ │ ├── 0052.cpp │ │ │ ├── 0053.cpp │ │ │ ├── 0041.cpp │ │ │ ├── 0045.cpp │ │ │ ├── 0218.cpp │ │ │ ├── 0001.cpp_disabled │ │ │ ├── 0209.cpp │ │ │ └── 0207.cpp │ │ │ ├── singleTUAA │ │ │ ├── 0064.cpp │ │ │ ├── 0242.cpp │ │ │ ├── 0114.cpp │ │ │ ├── 0061.cpp │ │ │ ├── 0069.cpp │ │ │ ├── 0241.cpp │ │ │ ├── 0244.cpp │ │ │ ├── 0245.cpp │ │ │ ├── 0243.cpp │ │ │ ├── 0062.cpp │ │ │ └── 0067.cpp │ │ │ ├── virtualCalls │ │ │ ├── 0006.cpp │ │ │ ├── 0007.cpp │ │ │ ├── 0008.cpp │ │ │ ├── 0009.cpp │ │ │ ├── 0011.cpp │ │ │ ├── 0012.cpp │ │ │ ├── 0019.cpp │ │ │ ├── 0020.cpp │ │ │ ├── 0016.cpp │ │ │ ├── 0015.cpp │ │ │ ├── 0018.cpp │ │ │ ├── 0021.cpp │ │ │ └── 0017.cpp │ │ │ └── cxxRecordCalls │ │ │ ├── 0018.cpp │ │ │ ├── 0008.cpp │ │ │ ├── 0016.cpp │ │ │ ├── 0009.cpp │ │ │ ├── 0003.cpp │ │ │ ├── 0006.cpp │ │ │ ├── 0014.cpp │ │ │ ├── 0017.cpp │ │ │ ├── 0007.cpp │ │ │ ├── 0012.cpp │ │ │ ├── 0013.cpp │ │ │ ├── 0015.cpp │ │ │ ├── 0001.cpp │ │ │ ├── 0004.cpp │ │ │ ├── 0002.cpp │ │ │ ├── 0010.cpp │ │ │ ├── 0011.cpp │ │ │ └── 0005.cpp_disabled │ ├── .gitignore │ └── fileInfoDemoPlugin │ │ └── CMakeLists.txt └── CMakeLists.txt ├── cgcollector ├── test │ ├── input │ │ ├── singleTU │ │ │ ├── 0063.gtipcg │ │ │ ├── 0001.cpp │ │ │ ├── 0002.cpp │ │ │ ├── 0233.cpp │ │ │ ├── 0022.cpp │ │ │ ├── 0222.cpp │ │ │ ├── 0226.cpp │ │ │ ├── 0066.cpp │ │ │ ├── 0003.cpp │ │ │ ├── 0215.cpp │ │ │ ├── 0005.cpp │ │ │ ├── 0227.cpp │ │ │ ├── 0004.cpp │ │ │ ├── 0063.cpp │ │ │ ├── 0013.cpp │ │ │ ├── 0014.cpp │ │ │ ├── 0063.gtmcg │ │ │ ├── 0223.cpp │ │ │ ├── 0234.cpp │ │ │ ├── 0001.gtipcg │ │ │ ├── 0022.gtipcg │ │ │ ├── 0222.gtipcg │ │ │ ├── 0233.gtipcg │ │ │ ├── 0221.gtipcg │ │ │ ├── 0221.cpp │ │ │ ├── 0228.gtipcg │ │ │ ├── 0224.cpp │ │ │ ├── 0235.cpp │ │ │ ├── 0232.cpp │ │ │ ├── 0228.cpp │ │ │ ├── 0230.cpp │ │ │ ├── 0237.cpp │ │ │ ├── 0065.cpp │ │ │ ├── 0004.gtipcg │ │ │ ├── 0226.gtipcg │ │ │ └── 0227.gtipcg │ │ ├── multiTU │ │ │ ├── 0070_b.cpp │ │ │ ├── 0043_a.cpp │ │ │ ├── 0042_a.cpp │ │ │ ├── 0044_b.cpp │ │ │ ├── 0053_a.cpp │ │ │ ├── 0043_b.cpp │ │ │ ├── 0044_a.cpp │ │ │ ├── 0214_b.cpp │ │ │ ├── 0060_b.cpp │ │ │ ├── 0050_a.cpp │ │ │ ├── 0042_b.cpp │ │ │ ├── 0050_b.cpp │ │ │ ├── 0050.h │ │ │ ├── 0071_b.cpp │ │ │ ├── 0070_a.cpp │ │ │ ├── 0053.h │ │ │ ├── 0214_a.cpp │ │ │ ├── 0241_b.cpp │ │ │ ├── 0071_a.cpp │ │ │ ├── 0240_a.cpp │ │ │ ├── 0053_b.cpp │ │ │ ├── 0240_b.cpp │ │ │ ├── 0072_b.cpp │ │ │ ├── 0072_a.cpp │ │ │ └── 0043_a.gtipcg │ │ ├── 0200 │ │ │ ├── m2.cpp │ │ │ ├── m2.h │ │ │ └── m1.cpp │ │ ├── 0201 │ │ │ ├── m2.cpp │ │ │ ├── m2.h │ │ │ ├── m3.h │ │ │ ├── m3.cpp │ │ │ └── m1.cpp │ │ ├── metaCollectors │ │ │ └── numStatements │ │ │ │ ├── 0041.cpp │ │ │ │ ├── 0023.cpp │ │ │ │ ├── 0024.cpp │ │ │ │ ├── 0025.cpp │ │ │ │ ├── 0026.cpp │ │ │ │ ├── 0027.cpp │ │ │ │ ├── 0028.cpp │ │ │ │ ├── 0038.cpp │ │ │ │ ├── 0037.cpp │ │ │ │ ├── 0039.cpp │ │ │ │ ├── 0029.cpp │ │ │ │ ├── 0034.cpp │ │ │ │ ├── 0023.gtipcg │ │ │ │ ├── 0024.gtipcg │ │ │ │ ├── 0025.gtipcg │ │ │ │ ├── 0026.gtipcg │ │ │ │ ├── 0027.gtipcg │ │ │ │ ├── 0028.gtipcg │ │ │ │ ├── 0029.gtipcg │ │ │ │ ├── 0042.cpp │ │ │ │ ├── 0030.cpp │ │ │ │ ├── 0035.cpp │ │ │ │ ├── 0031.cpp │ │ │ │ ├── 0036.cpp │ │ │ │ ├── 0040.cpp │ │ │ │ ├── 0032.cpp │ │ │ │ └── 0033.cpp │ │ ├── allCtorDtor │ │ │ ├── 0002.cpp │ │ │ ├── 0005.cpp │ │ │ ├── 0004.cpp │ │ │ ├── 0001.cpp │ │ │ ├── 0006.cpp │ │ │ ├── 0007.cpp │ │ │ ├── 0008.cpp │ │ │ └── 0003.cpp │ │ ├── functionPointers │ │ │ ├── 0216.cpp │ │ │ ├── 0208.cpp │ │ │ ├── 0201.cpp │ │ │ ├── 0211.cpp │ │ │ ├── 0202.cpp │ │ │ ├── 0205.cpp │ │ │ ├── 0214.cpp │ │ │ ├── 0100.cpp │ │ │ ├── 0212.cpp │ │ │ ├── 0210.cpp │ │ │ ├── 0101.cpp │ │ │ ├── 0049.cpp │ │ │ ├── 0103.cpp │ │ │ ├── 0213.cpp │ │ │ ├── 0102.cpp │ │ │ ├── 0115.cpp │ │ │ ├── 0204.cpp │ │ │ ├── 0206.cpp │ │ │ ├── 0217.cpp │ │ │ ├── 0048.cpp │ │ │ ├── 0203.cpp │ │ │ ├── 0051.cpp │ │ │ ├── 0047.cpp │ │ │ ├── 0053.cpp │ │ │ ├── 0046.cpp │ │ │ ├── 0052.cpp │ │ │ ├── 0209.cpp │ │ │ ├── 0041.cpp │ │ │ ├── 0045.cpp │ │ │ ├── 0207.cpp │ │ │ └── 0100.gtipcg │ │ ├── singleTUAA │ │ │ ├── 0064.cpp │ │ │ ├── 0242.cpp │ │ │ ├── 0114.cpp │ │ │ ├── 0061.cpp │ │ │ ├── 0069.cpp │ │ │ ├── 0241.cpp │ │ │ ├── 0244.cpp │ │ │ ├── 0245.cpp │ │ │ ├── 0062.cpp │ │ │ ├── 0243.cpp │ │ │ └── 0067.cpp │ │ └── virtualCalls │ │ │ ├── 0006.cpp │ │ │ ├── 0007.cpp │ │ │ ├── 0008.cpp │ │ │ ├── 0009.cpp │ │ │ ├── 0011.cpp │ │ │ ├── 0012.cpp │ │ │ ├── 0019.cpp │ │ │ ├── 0020.cpp │ │ │ ├── 0016.cpp │ │ │ ├── 0015.cpp │ │ │ ├── 0018.cpp │ │ │ ├── 0021.cpp │ │ │ └── 0017.cpp │ ├── integration │ │ ├── cgvalidate │ │ │ ├── input │ │ │ │ ├── fix │ │ │ │ │ ├── 0001.cubex │ │ │ │ │ └── 0001.cpp │ │ │ │ ├── general │ │ │ │ │ ├── 0001.cubex │ │ │ │ │ └── 0001.cpp │ │ │ │ ├── virtual │ │ │ │ │ ├── exp1.cubex │ │ │ │ │ ├── exp2.cubex │ │ │ │ │ ├── exp3.cubex │ │ │ │ │ ├── exp4.cubex │ │ │ │ │ ├── exp2.cpp │ │ │ │ │ ├── exp1.cpp │ │ │ │ │ ├── exp3.cpp │ │ │ │ │ ├── exp2.ipcg │ │ │ │ │ └── exp4.cpp │ │ │ │ └── fixvirtual │ │ │ │ │ ├── exp1.cubex │ │ │ │ │ └── exp1.cpp │ │ │ └── base.sh │ │ └── runner.sh │ ├── README.md │ └── CMakeLists.txt ├── lib │ └── include │ │ ├── GlobalCallDepth.h │ │ └── Utils.h ├── .clang-tidy └── formatAllSrc.sh ├── pgis ├── test │ ├── integration │ │ ├── inputdynamic │ │ │ ├── 001.afl │ │ │ ├── 002.afl │ │ │ ├── 003.afl │ │ │ ├── 004.afl │ │ │ ├── 005.afl │ │ │ ├── 006.afl │ │ │ ├── 007.afl │ │ │ ├── 008.afl │ │ │ ├── 009.afl │ │ │ ├── 001.cubex │ │ │ ├── 002.cubex │ │ │ ├── 003.cubex │ │ │ ├── 004.cubex │ │ │ ├── 005.cubex │ │ │ ├── 006.cubex │ │ │ ├── 007.cubex │ │ │ ├── 008.cubex │ │ │ ├── 009.cubex │ │ │ ├── 002.c │ │ │ ├── 003.c │ │ │ ├── 004.c │ │ │ ├── 001.c │ │ │ ├── dynamic_run.sh │ │ │ ├── 005.c │ │ │ └── dynamic_run_v2.sh │ │ ├── inputstatic │ │ │ ├── 001.afl │ │ │ ├── 002.afl │ │ │ ├── 003.afl │ │ │ ├── 004.afl │ │ │ ├── 006.afl │ │ │ ├── 005.afl │ │ │ ├── 009.spl │ │ │ ├── 008.spl │ │ │ ├── 007.spl │ │ │ ├── 001.ipcg │ │ │ ├── static_run.sh │ │ │ ├── static_run_v2.sh │ │ │ └── 003.ipcg │ │ ├── .gitignore │ │ ├── inputmodeling │ │ │ ├── 001.afl │ │ │ ├── 002.afl │ │ │ ├── 001 │ │ │ │ └── i0 │ │ │ │ │ ├── t.X2.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X12.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X22.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X32.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ └── t.X42.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ ├── 002 │ │ │ │ └── i0 │ │ │ │ │ ├── t.X3.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X3.postfix.r2 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X3.postfix.r3 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X3.postfix.r4 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X3.postfix.r5 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X5.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X5.postfix.r2 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X5.postfix.r3 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X5.postfix.r4 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X5.postfix.r5 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X7.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X7.postfix.r2 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X7.postfix.r3 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X7.postfix.r4 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X7.postfix.r5 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X9.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X9.postfix.r2 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X9.postfix.r3 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X9.postfix.r4 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X9.postfix.r5 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X11.postfix.r1 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X11.postfix.r2 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X11.postfix.r3 │ │ │ │ │ └── profile.cubex │ │ │ │ │ ├── t.X11.postfix.r4 │ │ │ │ │ └── profile.cubex │ │ │ │ │ └── t.X11.postfix.r5 │ │ │ │ │ └── profile.cubex │ │ │ ├── parameters.json │ │ │ ├── 001.json │ │ │ ├── 002.json │ │ │ ├── 001.c │ │ │ └── 002.c │ │ ├── ipcgread │ │ │ ├── 004.ipcg │ │ │ ├── 002.ipcg │ │ │ ├── 003.ipcg │ │ │ ├── 005.ipcg │ │ │ ├── 006.ipcg │ │ │ └── 001.ipcg │ │ └── inputimbalance │ │ │ ├── 003.afl │ │ │ ├── 002.afl │ │ │ ├── 001.afl │ │ │ ├── 001.cubex │ │ │ ├── 002.cubex │ │ │ ├── 003.cubex │ │ │ ├── imbalance_run.sh │ │ │ ├── parameters.json │ │ │ └── imbalance_run_v2.sh │ └── unit │ │ └── CMakeLists.txt ├── .gitignore └── CMakeLists.txt ├── utils ├── CMakeLists.txt └── config │ └── CMakeLists.txt ├── graph ├── test │ ├── integration │ │ ├── TargetCollector │ │ │ ├── src │ │ │ │ ├── wholeProgramCG.ipcg │ │ │ │ ├── foo.expected │ │ │ │ ├── foo.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── main.expected │ │ │ │ └── wholeProgramCG.expected │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── foo.h │ │ ├── CallgraphMerge │ │ │ ├── input │ │ │ │ ├── 0043_a.cpp │ │ │ │ ├── 0044_b.cpp │ │ │ │ ├── 0042_a.cpp │ │ │ │ ├── 0053_a.cpp │ │ │ │ ├── 0043_b.cpp │ │ │ │ ├── 0044_a.cpp │ │ │ │ ├── 0060_b.cpp │ │ │ │ ├── 0050_a.cpp │ │ │ │ ├── 0042_b.cpp │ │ │ │ ├── 0050_b.cpp │ │ │ │ ├── 0043_both.cpp │ │ │ │ ├── 0044_both.cpp │ │ │ │ ├── 0050.h │ │ │ │ ├── 0053.h │ │ │ │ ├── 0042_both.cpp │ │ │ │ ├── 0050_both.cpp │ │ │ │ ├── 0053_b.cpp │ │ │ │ └── 0053_both.cpp │ │ │ └── MergeCountMD.cpp │ │ └── Performance │ │ │ └── CMakeLists.txt │ └── install │ │ └── CMakeLists.txt ├── include │ ├── metadata │ │ ├── custom │ │ │ └── .gitignore │ │ └── CustomMD.h.in │ └── CgTypes.h └── src │ └── MCGBaseInfo.cpp ├── Config.h.in ├── cmake ├── Config.cmake.in ├── Policies.cmake ├── install-config.cmake.in ├── GoogleTest.cmake ├── CubeLib.cmake └── ExtraP.cmake ├── formatSrc.sh ├── .ci-defaults-template.yml ├── .gitignore └── container ├── build_base_image.sh └── devel /pymetacg/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | build/ 3 | extern/ 4 | -------------------------------------------------------------------------------- /pymetacg/tests/.gitignore: -------------------------------------------------------------------------------- 1 | .pytest_cache/ 2 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/input/cgB_body.mcg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0063.gtipcg: -------------------------------------------------------------------------------- 1 | null 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/001.afl: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/002.afl: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/001.afl: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/002.afl: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/003.afl: -------------------------------------------------------------------------------- 1 | main 2 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/input/cgA_node_md.mcg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/input/cgB_edge_md.mcg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/input/cgB_node_md.mcg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(config) 2 | -------------------------------------------------------------------------------- /pgis/test/integration/.gitignore: -------------------------------------------------------------------------------- 1 | logging/ 2 | out*/ 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/004.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/006.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/003.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/004.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/005.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | -------------------------------------------------------------------------------- /pymetacg/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | pytest-cmake 3 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | bar 4 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | bar 4 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/005.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | bar 4 | -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/004.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": {} 3 | } 4 | -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/wholeProgramCG.ipcg: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/006.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | fooChild 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0070_b.cpp: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { return a; } -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/007.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | fooChildOne 4 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/003.afl: -------------------------------------------------------------------------------- 1 | main 2 | test 3 | imbalanced 4 | -------------------------------------------------------------------------------- /tools/cgpatch/test/integration/input/general/042_a.cpp: -------------------------------------------------------------------------------- 1 | void say_hello() {} 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/008.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | fooIntermediate 4 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/009.afl: -------------------------------------------------------------------------------- 1 | main 2 | foo 3 | fooIntermediate 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/0200/m2.cpp: -------------------------------------------------------------------------------- 1 | #include "m2.h" 2 | 3 | int foo() { return 0; } 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/0201/m2.cpp: -------------------------------------------------------------------------------- 1 | #include "m2.h" 2 | 3 | int foo() { return 0; } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0070_b.cpp: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { return a; } 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/002.afl: -------------------------------------------------------------------------------- 1 | main 2 | get_func_ptr 3 | imbalanced 4 | balanced -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/002.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/0200/m2.h: -------------------------------------------------------------------------------- 1 | #ifndef M2_H 2 | #define M2_H 3 | 4 | int foo(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/0201/m2.h: -------------------------------------------------------------------------------- 1 | #ifndef M2_H 2 | #define M2_H 3 | 4 | int foo(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/0201/m3.h: -------------------------------------------------------------------------------- 1 | #ifndef M3_H 2 | #define M3_H 3 | 4 | int booq(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0043_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | 3 | int bar() { return 2; } 4 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/001.afl: -------------------------------------------------------------------------------- 1 | test 2 | main 3 | function_pointer_test 4 | MPI_Barrier -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0042_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 42; } 2 | 3 | int baz() { return foo(); } 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0044_b.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 2; } 2 | 3 | int hf() { return foo(); } 4 | -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/003.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "parents": [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0053_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0053.h" 2 | 3 | int MyClassDerive::foo() { return 42; } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0043_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | 3 | int bar() { return 2; } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0044_b.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 2; } 2 | 3 | int hf() { return foo(); } 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/0200/m1.cpp: -------------------------------------------------------------------------------- 1 | #include "m2.h" 2 | 3 | int main() { 4 | foo(); 5 | 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/0201/m3.cpp: -------------------------------------------------------------------------------- 1 | #include "m3.h" 2 | 3 | #include "m2.h" 4 | 5 | int booq() { return foo(); } 6 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0043_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | 3 | int bar() { return 2; } 4 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0044_b.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 2; } 2 | 3 | int hf() { return foo(); } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0042_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 42; } 2 | 3 | int baz() { return foo(); } 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0001.cpp: -------------------------------------------------------------------------------- 1 | // no calls at all 2 | 3 | int main(int argc, char* argv[]) { return 0; } 4 | -------------------------------------------------------------------------------- /graph/include/metadata/custom/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is needed here to ensure that git does not ignore the empty directory -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0042_a.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 42; } 2 | 3 | int baz() { return foo(); } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0053_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0053.h" 2 | 3 | int MyClassDerive::foo() { return 42; } 4 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0053_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0053.h" 2 | 3 | int MyClassDerive::foo() { return 42; } 4 | -------------------------------------------------------------------------------- /tools/cgcollector2/.gitignore: -------------------------------------------------------------------------------- 1 | *.ipcg 2 | .clion.source.upload.marker 3 | .idea/ 4 | cmake-build-debug*/ 5 | test/log/ 6 | 7 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0001.cpp: -------------------------------------------------------------------------------- 1 | // no calls at all 2 | 3 | int main(int argc, char* argv[]) { return 0; } 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0043_b.cpp: -------------------------------------------------------------------------------- 1 | extern int bar(); 2 | 3 | int har() { return 4; } 4 | 5 | int goo() { return bar(); } 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0044_a.cpp: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | 3 | int bar() { return foo(); } 4 | 5 | int har() { return bar(); } 6 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/001.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/001.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/002.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/002.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/003.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/003.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/004.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/004.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/005.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/005.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/006.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/006.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/007.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/007.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/008.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/008.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/009.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputdynamic/009.cubex -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0214_b.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | extern func_t g_foo; 4 | 5 | void call_foo() { g_foo(); } 6 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/001.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputimbalance/001.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/002.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputimbalance/002.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/003.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputimbalance/003.cubex -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/005.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "parents": [], 5 | "overriddenFunctions": [] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0043_b.cpp: -------------------------------------------------------------------------------- 1 | extern int bar(); 2 | 3 | int har() { return 4; } 4 | 5 | int goo() { return bar(); } 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0060_b.cpp: -------------------------------------------------------------------------------- 1 | void split(); 2 | 3 | void loop() { 4 | while (true) { 5 | split(); 6 | break; 7 | } 8 | } -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0043_b.cpp: -------------------------------------------------------------------------------- 1 | extern int bar(); 2 | 3 | int har() { return 4; } 4 | 5 | int goo() { return bar(); } 6 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0044_a.cpp: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | 3 | int bar() { return foo(); } 4 | 5 | int har() { return bar(); } 6 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0214_b.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | extern func_t g_foo; 4 | 5 | void call_foo() { g_foo(); } 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0050_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveTwo : public Base { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0044_a.cpp: -------------------------------------------------------------------------------- 1 | extern int foo(); 2 | 3 | int bar() { return foo(); } 4 | 5 | int har() { return bar(); } 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0042_b.cpp: -------------------------------------------------------------------------------- 1 | int boo() { 2 | int a = 1; 3 | int b = 0; 4 | return a + b; 5 | } 6 | 7 | int bar() { return boo(); } 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0050_b.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveDerive : public Derive { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0060_b.cpp: -------------------------------------------------------------------------------- 1 | void split(); 2 | 3 | void loop() { 4 | while (true) { 5 | split(); 6 | break; 7 | } 8 | } -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/009.spl: -------------------------------------------------------------------------------- 1 | SCOREP_REGION_NAMES_BEGIN 2 | INCLUDE main 3 | INCLUDE hoo 4 | INCLUDE main -> bar 5 | SCOREP_REGION_NAMES_END 6 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0050_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveTwo : public Base { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0060_b.cpp: -------------------------------------------------------------------------------- 1 | void split(); 2 | 3 | void loop() { 4 | while (true) { 5 | split(); 6 | break; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Config.h.in: -------------------------------------------------------------------------------- 1 | #define MetaCG_VERSION_MAJOR @MetaCG_VERSION_MAJOR@ 2 | #define MetaCG_VERSION_MINOR @MetaCG_VERSION_MINOR@ 3 | #define MetaCG_GIT_SHA "@GIT_SHA1@" 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/0201/m1.cpp: -------------------------------------------------------------------------------- 1 | #include "m2.h" 2 | #include "m3.h" 3 | 4 | int main() { 5 | foo(); 6 | booq(); 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0041.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main(int argc, char** argv) { 3 | const auto l = []() {}; 4 | l(); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") 4 | check_required_components("@PROJECT_NAME@") 5 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0050_a.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveTwo : public Base { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0042_b.cpp: -------------------------------------------------------------------------------- 1 | int boo() { 2 | int a = 1; 3 | int b = 0; 4 | return a + b; 5 | } 6 | 7 | int bar() { return boo(); } 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0050_b.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveDerive : public Derive { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0002.cpp: -------------------------------------------------------------------------------- 1 | // one call to foo 2 | 3 | void foo() {} 4 | 5 | int main(int argc, char* argv[]) { 6 | foo(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0042_b.cpp: -------------------------------------------------------------------------------- 1 | int boo() { 2 | int a = 1; 3 | int b = 0; 4 | return a + b; 5 | } 6 | 7 | int bar() { return boo(); } 8 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0050_b.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveDerive : public Derive { 4 | virtual void foo() override {} 5 | }; 6 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/002.c: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 1; } 3 | 4 | int main(int argc, char **argv) { 5 | int a = foo(); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0233.cpp: -------------------------------------------------------------------------------- 1 | // Test for a new call invoving a builtin type 2 | int main() { 3 | int a = 1; 4 | int* bp = new int(a); 5 | int c = *bp; 6 | } -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/fix/0001.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/fix/0001.cubex -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0041.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main(int argc, char** argv) { 3 | const auto l = []() {}; 4 | l(); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0002.cpp: -------------------------------------------------------------------------------- 1 | struct Base {}; 2 | 3 | int main(int argc, char** argv) { 4 | Base* bp = new Base(); 5 | delete bp; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0050.h: -------------------------------------------------------------------------------- 1 | 2 | struct Base { 3 | virtual void foo() {} 4 | }; 5 | 6 | struct Derive : public Base { 7 | virtual void foo() override {} 8 | }; 9 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/general/0001.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/general/0001.cubex -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp1.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/virtual/exp1.cubex -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp2.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/virtual/exp2.cubex -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp3.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/virtual/exp3.cubex -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp4.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/virtual/exp4.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/008.spl: -------------------------------------------------------------------------------- 1 | SCOREP_REGION_NAMES_BEGIN 2 | INCLUDE main 3 | INCLUDE foo 4 | INCLUDE foo -> hoo 5 | INCLUDE bar -> hoo 6 | SCOREP_REGION_NAMES_END 7 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cgcollector2) 2 | add_subdirectory(cgmerge2) 3 | add_subdirectory(cgconvert) 4 | add_subdirectory(cgformat) 5 | add_subdirectory(cgdiff) 6 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/README.md: -------------------------------------------------------------------------------- 1 | # Integration tests 2 | 3 | ## Usages 4 | Run the test runner from this directory with: 5 | ``` 6 | ./run_tests.sh -b build 7 | ``` 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0071_b.cpp: -------------------------------------------------------------------------------- 1 | 2 | extern void* functionptr; 3 | 4 | typedef void (*Ftype)(); 5 | 6 | int main() { 7 | ((Ftype)functionptr)(); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/fixvirtual/exp1.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/cgcollector/test/integration/cgvalidate/input/fixvirtual/exp1.cubex -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0043_both.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 1; } 2 | 3 | int bar() { return 2; } 4 | 5 | int har() { return 4; } 6 | 7 | int goo() { return bar(); } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0002.cpp: -------------------------------------------------------------------------------- 1 | struct Base {}; 2 | 3 | int main(int argc, char** argv) { 4 | Base* bp = new Base(); 5 | delete bp; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0216.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | int main() { 5 | func_t a; 6 | a = []() {}; 7 | a(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0022.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int a = 2; 5 | int b = 2; 6 | 7 | int k = a * b; 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0222.cpp: -------------------------------------------------------------------------------- 1 | int x; 2 | 3 | int main() { 4 | int f = 5; 5 | f = 7; 6 | 7 | if (4) { 8 | return 0; 9 | } 10 | return 1 + 2 + x; 11 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0050.h: -------------------------------------------------------------------------------- 1 | 2 | struct Base { 3 | virtual void foo() {} 4 | }; 5 | 6 | struct Derive : public Base { 7 | virtual void foo() override {} 8 | }; 9 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0233.cpp: -------------------------------------------------------------------------------- 1 | // Test for a new call invoving a builtin type 2 | int main() { 3 | int a = 1; 4 | int* bp = new int(a); 5 | int c = *bp; 6 | } 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0226.cpp: -------------------------------------------------------------------------------- 1 | int foo(int arg[], int offset) { return arg[offset]; } 2 | 3 | struct A { 4 | int a; 5 | int b; 6 | }; 7 | 8 | int boo(struct A a) { return a.b; } -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0044_both.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 2; } 2 | 3 | int bar() { return foo(); } 4 | 5 | int har() { return bar(); } 6 | 7 | int hf() { return foo(); } -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0050.h: -------------------------------------------------------------------------------- 1 | 2 | struct Base { 3 | virtual void foo() {} 4 | }; 5 | 6 | struct Derive : public Base { 7 | virtual void foo() override {} 8 | }; 9 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001/i0/t.X2.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/001/i0/t.X2.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r2/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r2/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r3/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r3/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r4/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r4/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r5/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X3.postfix.r5/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r2/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r2/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r3/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r3/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r4/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r4/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r5/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X5.postfix.r5/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r2/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r2/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r3/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r3/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r4/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r4/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r5/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X7.postfix.r5/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r2/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r2/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r3/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r3/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r4/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r4/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r5/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X9.postfix.r5/profile.cubex -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0216.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | int main() { 5 | func_t a; 6 | a = []() {}; 7 | a(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0022.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int a = 2; 5 | int b = 2; 6 | 7 | int k = a * b; 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001/i0/t.X12.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/001/i0/t.X12.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001/i0/t.X22.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/001/i0/t.X22.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001/i0/t.X32.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/001/i0/t.X32.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001/i0/t.X42.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/001/i0/t.X42.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r1/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r1/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r2/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r2/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r3/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r3/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r4/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r4/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r5/profile.cubex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tudasc/MetaCG/HEAD/pgis/test/integration/inputmodeling/002/i0/t.X11.postfix.r5/profile.cubex -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/007.spl: -------------------------------------------------------------------------------- 1 | SCOREP_REGION_NAMES_BEGIN 2 | INCLUDE main 3 | INCLUDE foo 4 | INCLUDE bar 5 | INCLUDE foo -> hoo 6 | INCLUDE bar -> hoo 7 | SCOREP_REGION_NAMES_END 8 | -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/006.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "parents": [], 5 | "overriddenFunctions": [], 6 | "overriddenby": [], 7 | "isVirtual": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0222.cpp: -------------------------------------------------------------------------------- 1 | int x; 2 | 3 | int main() { 4 | int f = 5; 5 | f = 7; 6 | 7 | if (4) { 8 | return 0; 9 | } 10 | return 1 + 2 + x; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0070_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling different parameters across translation units 2 | int foo(int some_name, int); 3 | 4 | int main() { 5 | foo(1, 2); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0071_b.cpp: -------------------------------------------------------------------------------- 1 | 2 | extern void* functionptr; 3 | 4 | typedef void (*Ftype)(); 5 | 6 | int main() { 7 | ((Ftype)functionptr)(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0226.cpp: -------------------------------------------------------------------------------- 1 | int foo(int arg[], int offset) { return arg[offset]; } 2 | 3 | struct A { 4 | int a; 5 | int b; 6 | }; 7 | 8 | int boo(struct A a) { return a.b; 9 | } -------------------------------------------------------------------------------- /tools/cgpatch/test/integration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | ${CMAKE_CURRENT_SOURCE_DIR}/CGPIntegrationRunner.sh.in 3 | ${CMAKE_CURRENT_BINARY_DIR}/CGPIntegrationRunner.sh 4 | @ONLY 5 | ) 6 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0208.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct A { 3 | void foo() {} 4 | }; 5 | void bar(A* a, void (A::*f)()) { (a->*f)(); } 6 | int main() { 7 | A a; 8 | bar(&a, &A::foo); 9 | } 10 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0023.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k; ++i) { 7 | } 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0070_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling different parameters across translation units 2 | int foo(int some_name, int); 3 | 4 | int main() { 5 | foo(1, 2); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0002.cpp: -------------------------------------------------------------------------------- 1 | // one call to foo 2 | 3 | void foo() {} 4 | 5 | static void bar(){} 6 | 7 | int main(int argc, char* argv[]) { 8 | foo(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0053.h: -------------------------------------------------------------------------------- 1 | 2 | class MyClass { 3 | public: 4 | virtual int foo() = 0; 5 | }; 6 | 7 | class MyClassDerive : public MyClass { 8 | public: 9 | virtual int foo(); 10 | }; 11 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0214_a.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | func_t g_foo; 4 | 5 | void call_foo(); 6 | void foo() {} 7 | 8 | int main() { 9 | g_foo = foo; 10 | call_foo(); 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0066.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handling of builtin functions 2 | extern void foo(); 3 | 4 | int main() { 5 | int x = 0; 6 | if (__builtin_expect(x, 0)) 7 | foo(); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/foo.expected: -------------------------------------------------------------------------------- 1 | {"_Z3foov":{"callees":[],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":0,"overriddenBy":[],"overriddenFunctions":[],"parents":[]}} 2 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0024.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | } 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /pgis/.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .cproject 3 | .idea 4 | 5 | *.dot 6 | *.swp 7 | 8 | src/*.o 9 | src/*.d 10 | 11 | build/** 12 | deps/** 13 | cmake-build-debug/ 14 | cmake-build-default/ 15 | 16 | 17 | *.user 18 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0208.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct A { 3 | void foo() {} 4 | }; 5 | void bar(A* a, void (A::*f)()) { (a->*f)(); } 6 | int main() { 7 | A a; 8 | bar(&a, &A::foo); 9 | } 10 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0023.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k; ++i) { 7 | } 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0053.h: -------------------------------------------------------------------------------- 1 | 2 | class MyClass { 3 | public: 4 | virtual int foo() = 0; 5 | }; 6 | 7 | class MyClassDerive : public MyClass { 8 | public: 9 | virtual int foo(); 10 | }; 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0214_a.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | func_t g_foo; 4 | 5 | void call_foo(); 6 | void foo() {} 7 | 8 | int main() { 9 | g_foo = foo; 10 | call_foo(); 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0003.cpp: -------------------------------------------------------------------------------- 1 | // main -> foo -> bar 2 | 3 | int bar() { return 42; } 4 | 5 | int foo() { return bar(); } 6 | 7 | int main(int argc, char* argv[]) { 8 | foo(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /cgcollector/test/integration/runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | fails=0 4 | 5 | cd cgvalidate 6 | bash cgvalidate-run.sh -b "$1" 7 | 8 | fails=$(($fails+$?)) 9 | 10 | echo Failed tests: $fails 11 | exit $fails 12 | 13 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0053.h: -------------------------------------------------------------------------------- 1 | 2 | class MyClass { 3 | public: 4 | virtual int foo() = 0; 5 | }; 6 | 7 | class MyClassDerive : public MyClass { 8 | public: 9 | virtual int foo(); 10 | }; 11 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/003.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unistd.h" 3 | 4 | int foo() { 5 | sleep(10); 6 | return 0; 7 | } 8 | 9 | int main(int argc, char **argv) { 10 | int a = foo(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "Modeling": { 3 | "extrapolationThreshold": 2.1, 4 | "statementThreshold": 200, 5 | "modelAggregationStrategy": "FirstModel" 6 | } 7 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0215.cpp: -------------------------------------------------------------------------------- 1 | 2 | int* k; 3 | 4 | int foo(int k) { 5 | if (k == 42) { 6 | return 0; 7 | } 8 | return foo(k); 9 | } 10 | 11 | int main() { 12 | foo(42); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001.json: -------------------------------------------------------------------------------- 1 | { 2 | "dir": "./001", 3 | "prefix": "t", 4 | "postfix": "postfix", 5 | "reps": 1, 6 | "iter": 1, 7 | "params" : { 8 | "X": ["2", "12", "22", "32", "42"] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002.json: -------------------------------------------------------------------------------- 1 | { 2 | "dir": "./002", 3 | "prefix": "t", 4 | "postfix": "postfix", 5 | "reps": 5, 6 | "iter": 1, 7 | "params" : { 8 | "X": ["3", "5", "7", "9", "11"] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0024.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | } 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0201.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void foo() {}; 5 | 6 | func_t get_f(func_t f) { return f; } 7 | 8 | int main() { 9 | func_t f = get_f(foo); 10 | f(); 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0211.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | 10 | int main() { 11 | A a; 12 | a.f = foo; 13 | a.f(); 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0025.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | } 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0003.cpp: -------------------------------------------------------------------------------- 1 | // main -> foo -> bar 2 | 3 | int bar() { return 42; } 4 | 5 | int foo() { return bar(); } 6 | 7 | int main(int argc, char* argv[]) { 8 | foo(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0066.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handling of builtin functions 2 | extern void foo(); 3 | 4 | int main() { 5 | int x = 0; 6 | if (__builtin_expect(x, 0)) 7 | foo(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0215.cpp: -------------------------------------------------------------------------------- 1 | 2 | int* k; 3 | 4 | int foo(int k) { 5 | if (k == 42) { 6 | return 0; 7 | } 8 | return foo(k); 9 | } 10 | 11 | int main() { 12 | foo(42); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0005.cpp: -------------------------------------------------------------------------------- 1 | // Tests if the destruction of local variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { B b; } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0202.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void foo() {} 5 | 6 | void cast() { 7 | func_t f; 8 | f = reinterpret_cast(reinterpret_cast(foo)); 9 | f(); 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0201.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void foo() {}; 5 | 6 | func_t get_f(func_t f) { return f; } 7 | 8 | int main() { 9 | func_t f = get_f(foo); 10 | f(); 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0211.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | 10 | int main() { 11 | A a; 12 | a.f = foo; 13 | a.f(); 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0205.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | void foo() {} 4 | void bar() {} 5 | 6 | int main() { 7 | func_t a, b; 8 | bool s = true; 9 | (s ? a : b) = foo; 10 | (s ? a : b)(); 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0241_b.cpp: -------------------------------------------------------------------------------- 1 | using Ftype = void(); 2 | 3 | struct Base { 4 | virtual int foo(); 5 | Ftype* f; 6 | }; 7 | 8 | void calc(Base* arg) { 9 | //(*arg).foo(); 10 | arg->foo(); 11 | arg->f(); 12 | } 13 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0042_both.cpp: -------------------------------------------------------------------------------- 1 | int foo() { return 42; } 2 | 3 | int baz() { return foo(); } 4 | 5 | int boo() { 6 | int a = 1; 7 | int b = 0; 8 | return a + b; 9 | } 10 | 11 | int bar() { return boo(); } -------------------------------------------------------------------------------- /graph/test/integration/Performance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PROJECT_NAME PerfTest) 2 | set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-target) 3 | 4 | add_executable(perftest PerfTester.cpp) 5 | add_metacg(perftest) 6 | 7 | add_config_include(perftest) 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0202.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void foo() {} 5 | 6 | void cast() { 7 | func_t f; 8 | f = reinterpret_cast(reinterpret_cast(foo)); 9 | f(); 10 | } 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0025.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | } 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0214.cpp: -------------------------------------------------------------------------------- 1 | typedef void (*func_t)(); 2 | 3 | void foo(func_t fp) {} 4 | void bar() {} 5 | 6 | int main(int argc, char** argv) { 7 | func_t f; 8 | f = bar; 9 | foo(f); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0050_both.cpp: -------------------------------------------------------------------------------- 1 | #include "0050.h" 2 | 3 | struct DeriveTwo : public Base { 4 | virtual void foo() override {} 5 | }; 6 | 7 | struct DeriveDerive : public Derive { 8 | virtual void foo() override {} 9 | }; -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0005.cpp: -------------------------------------------------------------------------------- 1 | // Tests if the destruction of local variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { B b; } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0241_b.cpp: -------------------------------------------------------------------------------- 1 | using Ftype = void(); 2 | 3 | struct Base { 4 | virtual int foo(); 5 | Ftype* f; 6 | }; 7 | 8 | void calc(Base* arg) { 9 | //(*arg).foo(); 10 | arg->foo(); 11 | arg->f(); 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgpatch/test/integration/input/general/042_b.cpp: -------------------------------------------------------------------------------- 1 | extern void say_hello(); 2 | int main() { 3 | void (*fptr)(); // declare function pointer 4 | fptr = say_hello; // assign the function to the pointer 5 | fptr(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0100.cpp: -------------------------------------------------------------------------------- 1 | // function pointer without hit 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int main(int argc, char* argv[]) { 6 | int (*function)(); 7 | 8 | function(); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cmake/Policies.cmake: -------------------------------------------------------------------------------- 1 | function(set_policies) 2 | # Choose modern CMake behavior when extracting archives 3 | if(POLICY CMP0135) 4 | cmake_policy( 5 | SET 6 | CMP0135 7 | NEW 8 | ) 9 | endif() 10 | endfunction() 11 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0214.cpp: -------------------------------------------------------------------------------- 1 | typedef void (*func_t)(); 2 | 3 | void foo(func_t fp) {} 4 | void bar() {} 5 | 6 | int main(int argc, char** argv) { 7 | func_t f; 8 | f = bar; 9 | foo(f); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0005.cpp: -------------------------------------------------------------------------------- 1 | // two functions called independently from main 2 | 3 | void childOne() {} 4 | void childTwo() {} 5 | 6 | int main(int argc, char* argv[]) { 7 | childOne(); 8 | childTwo(); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0227.cpp: -------------------------------------------------------------------------------- 1 | float foo(float a, int b) { return a * b; } 2 | 3 | float g; 4 | double h; 5 | 6 | void baa(float* arr, int count) { 7 | for (int i = 0; i < count; ++i) { 8 | g *= arr[i]; 9 | } 10 | h++; 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0100.cpp: -------------------------------------------------------------------------------- 1 | // function pointer without hit 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int main(int argc, char* argv[]) { 6 | int (*function)(); 7 | 8 | function(); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0064.cpp: -------------------------------------------------------------------------------- 1 | // Test for typedef for functions 2 | 3 | void foo(int n) { int inner = n; } 4 | 5 | typedef void (*Ftype)(int); 6 | 7 | int main() { 8 | Ftype f = &foo; 9 | int arg = 5; 10 | f(arg); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0227.cpp: -------------------------------------------------------------------------------- 1 | float foo(float a, int b) { return a * b; } 2 | 3 | float g; 4 | double h; 5 | 6 | void baa(float* arr, int count) { 7 | for (int i = 0; i < count; ++i) { 8 | g *= arr[i]; 9 | } 10 | h++; 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0004.cpp: -------------------------------------------------------------------------------- 1 | // no call 2 | // but a second function 3 | 4 | int foo() { 5 | int a = 0; 6 | for (int i = 0; i < 5; ++i) { 7 | a += 2; 8 | } 9 | return a; 10 | } 11 | 12 | int main(int argc, char* argv[]) { return 0; } 13 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp2.cpp: -------------------------------------------------------------------------------- 1 | struct A { 2 | virtual int foo() { return 42; } 3 | }; 4 | 5 | struct D : public A {}; 6 | 7 | void someFunc(D* d) { d->foo(); } 8 | 9 | int main() { 10 | D d; 11 | someFunc(&d); 12 | } 13 | -------------------------------------------------------------------------------- /formatSrc.sh: -------------------------------------------------------------------------------- 1 | # Apply formatting only to tracked changes 2 | git-clang-format devel 3 | 4 | # Apply CMake formatting 5 | find . -name "CMakeLists.txt" -exec cmake-format -i {} \; 6 | find ./cmake -name "*.cmake" -o -name "*.cmake.in" -type f -exec cmake-format -i {} \; 7 | -------------------------------------------------------------------------------- /pgis/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PROJECT_NAME PGIS) 2 | set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-target) 3 | 4 | add_subdirectory(lib) 5 | add_subdirectory(tool) 6 | 7 | if(METACG_BUILD_UNIT_TESTS) 8 | enable_testing() 9 | add_subdirectory(test/unit) 10 | endif() 11 | -------------------------------------------------------------------------------- /pgis/test/integration/ipcgread/001.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "parents": [], 5 | "isVirtual": false, 6 | "hasBody": false, 7 | "doesOverride": false, 8 | "numStatements": 0, 9 | "overriddenFunctions": [], 10 | "overriddenBy": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0005.cpp: -------------------------------------------------------------------------------- 1 | // two functions called independently from main 2 | 3 | void childOne() {} 4 | void childTwo() {} 5 | 6 | int main(int argc, char* argv[]) { 7 | childOne(); 8 | childTwo(); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgdiff/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(cgdiff CGDiff.cpp) 2 | 3 | target_include_directories(cgdiff PRIVATE include) 4 | 5 | add_metacg(cgdiff) 6 | add_cxxopts(cgdiff) 7 | 8 | if(METACG_BUILD_UNIT_TESTS) 9 | add_subdirectory(test/unit) 10 | endif() 11 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0006.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and member function 2 | 3 | class MyClass { 4 | public: 5 | void foo() {} 6 | }; 7 | 8 | int main(int argc, char* argv[]) { 9 | MyClass mc; 10 | mc.foo(); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0004.cpp: -------------------------------------------------------------------------------- 1 | // The destructor ~A() should appear an (implicit) callee of ~B(). 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { 12 | B* b = new B; 13 | delete b; 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0212.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | void call_f(const A& arg) { arg.f(); } 10 | 11 | int main() { 12 | A a; 13 | a.f = foo; 14 | call_f(a); 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0063.cpp: -------------------------------------------------------------------------------- 1 | // This test is for checking that the Alias Analysis does not assume that __status and __arg are parameters to on_exit 2 | // Tests function types in a parameter 3 | extern int on_exit(void (*__func)(int __status, void* __arg), void* __arg); -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/general/0001.cpp: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | 3 | int bar() { 4 | foo(); 5 | return 0; 6 | } 7 | 8 | void notcalled() { bar(); } 9 | 10 | int main(int argc, char** argv) { 11 | foo(); 12 | bar(); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0004.cpp: -------------------------------------------------------------------------------- 1 | // no call 2 | // but a second function 3 | 4 | int foo() { 5 | int a = 0; 6 | for (int i = 0; i < 5; ++i) { 7 | a += 2; 8 | } 9 | return a; 10 | } 11 | 12 | int main(int argc, char* argv[]) { return 0; } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0064.cpp: -------------------------------------------------------------------------------- 1 | // Test for typedef for functions 2 | 3 | void foo(int n) { int inner = n; } 4 | 5 | typedef void (*Ftype)(int); 6 | 7 | int main() { 8 | Ftype f = &foo; 9 | int arg = 5; 10 | f(arg); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0006.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and member function 2 | 3 | class MyClass { 4 | public: 5 | void foo() {} 6 | }; 7 | 8 | int main(int argc, char* argv[]) { 9 | MyClass mc; 10 | mc.foo(); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0001.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and virtual destructor 2 | 3 | class MyClass { 4 | public: 5 | MyClass() {} 6 | virtual ~MyClass() {} 7 | }; 8 | 9 | int main(int argc, char* argv[]) { 10 | MyClass mc; 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0210.cpp: -------------------------------------------------------------------------------- 1 | // Test fpr a lambda that is casted to a function pointer 2 | using func_t = void (*)(); 3 | 4 | int main() { 5 | func_t a, b; 6 | bool s = true; 7 | (s ? a : b) = []() {}; 8 | (s ? a : b)(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/foo.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: foo.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | #include "foo.h" 8 | 9 | void foo() {} -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0004.cpp: -------------------------------------------------------------------------------- 1 | // The destructor ~A() should appear an (implicit) callee of ~B(). 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { 12 | B* b = new B; 13 | delete b; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0210.cpp: -------------------------------------------------------------------------------- 1 | // Test for a lambda that is cast to a function pointer 2 | using func_t = void (*)(); 3 | int main() { 4 | func_t a, b; 5 | bool s = true; 6 | (s ? a : b) = []() {}; 7 | (s ? a : b)(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0101.cpp: -------------------------------------------------------------------------------- 1 | // function pointer without hit 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int hit1() { return 0; } 6 | 7 | int main(int argc, char* argv[]) { 8 | int (*function)(); 9 | 10 | function(); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0026.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | if (k % 2 == 0) { 10 | ++k; 11 | } 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/MergeCountMD.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: MergeCountMD.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | #include "MergeCountMD.h" 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0212.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | void call_f(const A& arg) { arg.f(); } 10 | 11 | int main() { 12 | A a; 13 | a.f = foo; 14 | call_f(a); 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/lib/include/GlobalCallDepth.h: -------------------------------------------------------------------------------- 1 | #ifndef CGCOLLECTOR_GLOBALCALLDEPTH_H 2 | #define CGCOLLECTOR_GLOBALCALLDEPTH_H 3 | 4 | #include 5 | 6 | void calculateGlobalCallDepth(nlohmann::json& j, bool useOnlyMainEntry); 7 | 8 | #endif // CGCOLLECTOR_GLOBALCALLDEPTH_H 9 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0006.cpp: -------------------------------------------------------------------------------- 1 | // Tests if the destruction of temporary local variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | B makeB() { return B(); } 12 | 13 | void foo() { makeB(); } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0049.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | typedef int (*Fn)(); 5 | 6 | Fn get(int i) { 7 | Fn f = one; 8 | return f; 9 | } 10 | 11 | Fn get2(int i) { return get(i); } 12 | 13 | int main() { 14 | get2(1)(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0071_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling function ptrs in a global variable across different TUs 2 | void function() { int a = 1 + 2; } 3 | 4 | void* functionptr; 5 | 6 | int foo() { 7 | void* var = (void*)&function; 8 | functionptr = var; 9 | return 1; 10 | } -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: main.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | #include "foo.h" 8 | 9 | int main() { foo(); } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0001.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and virtual destructor 2 | 3 | class MyClass { 4 | public: 5 | MyClass() {} 6 | virtual ~MyClass() {} 7 | }; 8 | 9 | int main(int argc, char* argv[]) { 10 | MyClass mc; 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0101.cpp: -------------------------------------------------------------------------------- 1 | // function pointer without hit 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int hit1() { return 0; } 6 | 7 | int main(int argc, char* argv[]) { 8 | int (*function)(); 9 | 10 | function(); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0026.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | if (k % 2 == 0) { 10 | ++k; 11 | } 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0013.cpp: -------------------------------------------------------------------------------- 1 | // call to multiple functions 2 | 3 | int lastChild() { return 1; } 4 | 5 | int middle() { return lastChild(); } 6 | 7 | int middle2() { return lastChild(); } 8 | 9 | int main(int argc, char* argv[]) { 10 | middle(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(TargetCollectorIntegrationTest) 4 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 5 | add_executable(testExe src/foo.cpp src/main.cpp) 6 | 7 | target_include_directories(testExe PRIVATE include) 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0006.cpp: -------------------------------------------------------------------------------- 1 | // Tests if the destruction of temporary local variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | B makeB() { return B(); } 12 | 13 | void foo() { makeB(); } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0063.cpp.disabled: -------------------------------------------------------------------------------- 1 | // This test is for checking that the Alias Analysis does not assume that __status and __arg are parameters to on_exit 2 | // Tests function types in a parameter 3 | extern int on_exit(void (*__func)(int __status, void *__arg), void *__arg); 4 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0103.cpp: -------------------------------------------------------------------------------- 1 | // function pointer with two hits 2 | 3 | void caller(int (*function)()) {} 4 | 5 | void foo() {} 6 | 7 | int hit() { return 5; } 8 | 9 | int main(int argc, char* argv[]) { 10 | caller(&hit); 11 | foo(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0213.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | func_t get_f(const A& a) { return a.f; } 10 | 11 | int main() { 12 | A a; 13 | a.f = foo; 14 | auto f = get_f(a); 15 | f(); 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0049.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | typedef int (*Fn)(); 5 | 6 | Fn get(int i) { 7 | Fn f = one; 8 | return f; 9 | } 10 | 11 | Fn get2(int i) { return get(i); } 12 | 13 | int main() { 14 | get2(1)(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0013.cpp: -------------------------------------------------------------------------------- 1 | // call to multiple functions 2 | 3 | int lastChild() { return 1; } 4 | 5 | int middle() { return lastChild(); } 6 | 7 | int middle2() { return lastChild(); } 8 | 9 | int main(int argc, char* argv[]) { 10 | middle(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: '-clang-analyzer-core*, 3 | -clang-analyzer-cplusplus*, 4 | -cppcoreguidelines-*, 5 | -cert-err61-cpp, 6 | -modernize-raw-string-literal, 7 | -modernize-make*, 8 | -performance* 9 | ' 10 | ... 11 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0027.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | if (k % 2 == 0) { 10 | ++k; 11 | } else { 12 | } 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0028.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | if (k % 2 == 0) { 8 | ++k; 9 | } else { 10 | ++i; 11 | ++k; 12 | } 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0103.cpp: -------------------------------------------------------------------------------- 1 | // function pointer with two hits 2 | 3 | void caller(int (*function)()) {} 4 | 5 | void foo() {} 6 | 7 | int hit() { return 5; } 8 | 9 | int main(int argc, char* argv[]) { 10 | caller(&hit); 11 | foo(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0205.cpp: -------------------------------------------------------------------------------- 1 | // This test is very heavily overestimated with mode "all" 2 | using func_t = void (*)(); 3 | void foo() {} 4 | void bar() {} 5 | 6 | int main() { 7 | func_t a, b; 8 | bool s = true; 9 | (s ? a : b) = foo; 10 | (s ? a : b)(); 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0213.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | struct A { 5 | func_t f; 6 | }; 7 | 8 | void foo() {} 9 | func_t get_f(const A& a) { return a.f; } 10 | 11 | int main() { 12 | A a; 13 | a.f = foo; 14 | auto f = get_f(a); 15 | f(); 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0071_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling function ptrs in a global variable across different TUs 2 | void function() { int a = 1 + 2; } 3 | 4 | void* functionptr; 5 | 6 | int foo() { 7 | void* var = (void*)&function; 8 | functionptr = var; 9 | return 1; 10 | } 11 | -------------------------------------------------------------------------------- /cgcollector/test/README.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ## CGSimpleTester 4 | 5 | The simple tests check whether the `cgcollector`'s generated `.json` files match a pre-generated file that was checked for its validity. 6 | It relies on the `==` operator defined by the used `nlohnmann::json` library for its json objects. 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0038.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | try { 12 | ++k; 13 | } catch (int ec) { 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cmake/install-config.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | find_dependency(Threads) 4 | 5 | if(@METACG_USE_EXTERNAL_JSON@) # only enabled when METACG_USE_EXTERNAL_JSON=ON 6 | find_dependency(nlohmann_json) 7 | endif() 8 | 9 | include("${CMAKE_CURRENT_LIST_DIR}/metacgTargets.cmake") 10 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/004.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unistd.h" 3 | 4 | int foo() { 5 | sleep(10); 6 | return 0; 7 | } 8 | 9 | int bar() { 10 | sleep(1); 11 | return 0; 12 | } 13 | 14 | int main(int argc, char **argv) { 15 | int a = foo(); 16 | int b = bar(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0027.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | ++i; 8 | --k; 9 | if (k % 2 == 0) { 10 | ++k; 11 | } else { 12 | } 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /utils/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(metacg-config MCGConfig.cpp) 2 | add_config_include(metacg-config) 3 | target_compile_definitions(metacg-config PRIVATE INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") 4 | add_cxxopts(metacg-config) 5 | 6 | install(TARGETS metacg-config DESTINATION ${CMAKE_INSTALL_BINDIR}) 7 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0007.cpp: -------------------------------------------------------------------------------- 1 | // Tests if non-virtual destructors are handled correctly. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { 12 | A* b = new B; 13 | // This should only call the destructor of A 14 | delete b; 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0037.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | do { 12 | i = k - 2; 13 | ++i; 14 | } while (i < k); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0014.cpp: -------------------------------------------------------------------------------- 1 | // call to multiple functions 2 | 3 | int lastChild() { return 1; } 4 | 5 | int middle2() { return lastChild(); } 6 | 7 | int middle() { return middle2(); } 8 | 9 | int main(int argc, char* argv[]) { 10 | middle(); 11 | lastChild(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /pymetacg/tests/resources/empty_cg.mcg: -------------------------------------------------------------------------------- 1 | { 2 | "_CG": {}, 3 | "_MetaCG": { 4 | "generator": { 5 | "name": "CGCollector", 6 | "sha": "05981c57fa438972b164ec3b164e256a00495637", 7 | "version": "0.7" 8 | }, 9 | "version": "2.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0028.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | 6 | for (int i = 0; i < k;) { 7 | if (k % 2 == 0) { 8 | ++k; 9 | } else { 10 | ++i; 11 | ++k; 12 | } 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0038.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | try { 12 | ++k; 13 | } catch (int ec) { 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0039.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | try { 12 | ++k; 13 | } catch (int ec) { 14 | ++i; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0063.gtmcg: -------------------------------------------------------------------------------- 1 | { 2 | "_CG": null, 3 | "_MetaCG": { 4 | "generator": { 5 | "name": "CGCollector", 6 | "sha": "9a42ed575dd43d75255b74cbfccb686af3e70e8b", 7 | "version": "0.3" 8 | }, 9 | "version": "2.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0223.cpp: -------------------------------------------------------------------------------- 1 | int x; 2 | 3 | int test() { 4 | do { 5 | return 1; 6 | } while (true); 7 | }; 8 | 9 | int main() { 10 | while (true) { 11 | int a; 12 | while (true) { 13 | break; 14 | } 15 | a = 0; 16 | break; 17 | } 18 | test(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0007.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and virtual destructor 2 | 3 | class MyClass { 4 | public: 5 | MyClass(int b) { int c = b; } 6 | virtual ~MyClass() {} 7 | }; 8 | 9 | int main(int argc, char* argv[]) { 10 | int a = 42; 11 | MyClass mc(a); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/fixvirtual/exp1.cpp: -------------------------------------------------------------------------------- 1 | struct A { 2 | virtual int foo() { return 42; } 3 | }; 4 | 5 | struct D : public A { 6 | virtual int foo() override { return 1; } 7 | }; 8 | 9 | void someFunc(A* a) { a->foo(); } 10 | 11 | int main() { 12 | D d; 13 | someFunc(&d); 14 | } 15 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp1.cpp: -------------------------------------------------------------------------------- 1 | struct A { 2 | virtual int foo() { return 42; } 3 | }; 4 | 5 | struct D : public A { 6 | virtual int foo() override { return 1; } 7 | }; 8 | 9 | void someFunc(A* a) { a->foo(); } 10 | 11 | int main() { 12 | D d; 13 | someFunc(&d); 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0014.cpp: -------------------------------------------------------------------------------- 1 | // call to multiple functions 2 | 3 | int lastChild() { return 1; } 4 | 5 | int middle2() { return lastChild(); } 6 | 7 | int middle() { return middle2(); } 8 | 9 | int main(int argc, char* argv[]) { 10 | middle(); 11 | lastChild(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0008.cpp: -------------------------------------------------------------------------------- 1 | // Tests if implicit destruction of member variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B { 8 | // ~A() should be called here. 9 | ~B(){}; 10 | A a; 11 | }; 12 | 13 | void foo() { 14 | B* b = new B; 15 | delete b; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0102.cpp: -------------------------------------------------------------------------------- 1 | // function pointer with two hits 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int hit1() { return 0; } 6 | 7 | int hit2() { return 5; } 8 | 9 | int main(int argc, char* argv[]) { 10 | int (*function)(); 11 | 12 | function(); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0007.cpp: -------------------------------------------------------------------------------- 1 | // Tests if non-virtual destructors are handled correctly. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B : A { 8 | ~B(){}; 9 | }; 10 | 11 | void foo() { 12 | A* b = new B; 13 | // This should only call the destructor of A 14 | delete b; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0037.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | do { 12 | i = k - 2; 13 | ++i; 14 | } while (i < k); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0029.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | int i = 0; 6 | 7 | while (i < k) { 8 | if (k % 2 == 0) { 9 | ++k; 10 | } else { 11 | ++i; 12 | ++k; 13 | } 14 | ++i; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0034.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | default: 13 | k = 11; 14 | break; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0102.cpp: -------------------------------------------------------------------------------- 1 | // function pointer with two hits 2 | 3 | int foo(float a) { return 0; } 4 | 5 | int hit1() { return 0; } 6 | 7 | int hit2() { return 5; } 8 | 9 | int main(int argc, char* argv[]) { 10 | int (*function)(); 11 | 12 | function(); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0039.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | try { 12 | ++k; 13 | } catch (int ec) { 14 | ++i; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0063.gtmcg: -------------------------------------------------------------------------------- 1 | { 2 | "_CG": null, 3 | "_MetaCG": { 4 | "generator": { 5 | "name": "CGCollector", 6 | "sha": "9a42ed575dd43d75255b74cbfccb686af3e70e8b", 7 | "version": "0.3" 8 | }, 9 | "version": "2.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0007.cpp: -------------------------------------------------------------------------------- 1 | // call to constructor and virtual destructor 2 | 3 | class MyClass { 4 | public: 5 | MyClass(int b) { int c = b; } 6 | virtual ~MyClass() {} 7 | }; 8 | 9 | int main(int argc, char* argv[]) { 10 | int a = 42; 11 | MyClass mc(a); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /.ci-defaults-template.yml: -------------------------------------------------------------------------------- 1 | default: 2 | before_script: 3 | - module purge 4 | - module load gcc/$GCC 5 | - module load git cmake python/3 6 | - module load libcube/4.5 extrap/3 7 | tags: 8 | - general 9 | 10 | variables: 11 | GIT_STRATEGY: none 12 | GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PIPELINE_ID 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0234.cpp: -------------------------------------------------------------------------------- 1 | // Tests an explicit destructor call 2 | typedef void (*Fn)(); 3 | 4 | void func1() {} 5 | 6 | class X { 7 | public: 8 | Fn function; 9 | X(Fn arg) { function = arg; } 10 | ~X() { function(); } 11 | }; 12 | 13 | int main() { 14 | const auto f = new X(func1); 15 | f->~X(); 16 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0008.cpp: -------------------------------------------------------------------------------- 1 | // Tests if implicit destruction of member variables is properly captured. 2 | 3 | struct A { 4 | ~A() {} 5 | }; 6 | 7 | struct B { 8 | // ~A() should be called here. 9 | ~B(){}; 10 | A a; 11 | }; 12 | 13 | void foo() { 14 | B* b = new B; 15 | delete b; 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0029.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | int main(int argc, char** argv) { 4 | int k = 12; 5 | int i = 0; 6 | 7 | while (i < k) { 8 | if (k % 2 == 0) { 9 | ++k; 10 | } else { 11 | ++i; 12 | ++k; 13 | } 14 | ++i; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0034.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | default: 13 | k = 11; 14 | break; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0223.cpp: -------------------------------------------------------------------------------- 1 | int x; 2 | 3 | int test() { 4 | do { 5 | return 1; 6 | } while (true); 7 | }; 8 | 9 | int main() { 10 | while (true) { 11 | int a; 12 | while (true) { 13 | break; 14 | } 15 | a = 0; 16 | break; 17 | } 18 | test(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0115.cpp: -------------------------------------------------------------------------------- 1 | // Test for unions involving function pointers 2 | extern void foo(); 3 | using FType = decltype(foo); 4 | 5 | class C { 6 | public: 7 | union { 8 | int i; 9 | FType* f; 10 | }; 11 | }; 12 | 13 | int main() { 14 | C c; 15 | c.i = 4; 16 | c.f = foo; 17 | c.f(); 18 | } -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0204.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | void call_func2(func_t f) { 4 | auto f2 = f; 5 | f(); 6 | } 7 | void call_func(func_t f) { 8 | auto f2 = f; 9 | call_func2(f2); 10 | } 11 | void foo() {} 12 | int main() { 13 | func_t f = foo; 14 | call_func(f); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0240_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling default args/ differing definitions accross translation units 2 | extern void some_function(); 3 | extern void some_other_function(); 4 | using FType = decltype(some_function); 5 | 6 | void f(FType n = some_function, FType arg = some_other_function); 7 | 8 | void work() { f(); } 9 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0001.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0022.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 4, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0222.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 5, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0233.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 3, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/001.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0206.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | void foo() {} 4 | void bar() {} 5 | 6 | void call() { 7 | func_t a, b; 8 | bool s = true; 9 | if (s) 10 | a = foo; 11 | else 12 | b = foo; 13 | if (s) 14 | a(); 15 | else 16 | b(); 17 | } 18 | 19 | int main() { call(); } 20 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0217.cpp: -------------------------------------------------------------------------------- 1 | // Test passing a variable through a lambda that is cast to a fptr 2 | using func_t = int (*)(int); 3 | 4 | int main() { 5 | func_t lamb = [](int a) { 6 | int tmp = a; 7 | return tmp; 8 | }; 9 | int parameter = 0; 10 | int result = lamb(parameter); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0053_b.cpp: -------------------------------------------------------------------------------- 1 | // call to redefining function 2 | 3 | #include "0053.h" 4 | 5 | class MyClassDeriveD : public MyClassDerive { 6 | public: 7 | int foo() { return 1; } 8 | }; 9 | 10 | int main(int argc, char* argv[]) { 11 | MyClass* m = new MyClassDeriveD(); 12 | m->foo(); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0221.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 10, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0204.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | void call_func2(func_t f) { 4 | auto f2 = f; 5 | f(); 6 | } 7 | void call_func(func_t f) { 8 | auto f2 = f; 9 | call_func2(f2); 10 | } 11 | void foo() {} 12 | int main() { 13 | func_t f = foo; 14 | call_func(f); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0048.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | get2(1)(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0206.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | void foo() {} 4 | void bar() {} 5 | 6 | void call() { 7 | func_t a, b; 8 | bool s = true; 9 | if (s) 10 | a = foo; 11 | else 12 | b = foo; 13 | if (s) 14 | a(); 15 | else 16 | b(); 17 | } 18 | 19 | int main() { call(); } 20 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0240_a.cpp: -------------------------------------------------------------------------------- 1 | // Test for handling default args/ differing definitions accross translation units 2 | extern void some_function(); 3 | extern void some_other_function(); 4 | using FType = decltype(some_function); 5 | 6 | void f(FType n = some_function, FType arg = some_other_function); 7 | 8 | void work() { f(); } 9 | -------------------------------------------------------------------------------- /cgcollector/test/input/allCtorDtor/0003.cpp: -------------------------------------------------------------------------------- 1 | // Member b of A is default-initialized, this must be caught by cgcollector. 2 | // This will lead to a callpath existing from A() through B() to hidden() 3 | 4 | void hidden() {} 5 | 6 | struct B { 7 | int* data; 8 | B() { hidden(); } 9 | }; 10 | 11 | struct A { 12 | A() {} 13 | 14 | B b; 15 | }; -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0221.cpp: -------------------------------------------------------------------------------- 1 | // Test branch 2 | 3 | int main() { 4 | bool a = 5 ? false : true; 5 | int b = 7; 6 | if (a) { 7 | switch (b) { 8 | default: 9 | break; 10 | } 11 | } else if (b) { 12 | bool f = true; 13 | while (f) { 14 | f = false; 15 | } 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0115.cpp: -------------------------------------------------------------------------------- 1 | // Test for unions involving function pointers 2 | extern void foo(); 3 | using FType = decltype(foo); 4 | 5 | class C { 6 | public: 7 | union { 8 | int i; 9 | FType* f; 10 | }; 11 | }; 12 | 13 | int main() { 14 | C c; 15 | c.i = 4; 16 | c.f = foo; 17 | c.f(); 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0217.cpp: -------------------------------------------------------------------------------- 1 | // Test passing a variable through a lambda that is cast to a fptr 2 | using func_t = int (*)(int); 3 | 4 | int main() { 5 | func_t lamb = [](int a) { 6 | int tmp = a; 7 | return tmp; 8 | }; 9 | int parameter = 0; 10 | int result = lamb(parameter); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0053_b.cpp: -------------------------------------------------------------------------------- 1 | // call to redefining function 2 | 3 | #include "0053.h" 4 | 5 | class MyClassDeriveD : public MyClassDerive { 6 | public: 7 | int foo() { return 1; } 8 | }; 9 | 10 | int main(int argc, char* argv[]) { 11 | MyClass* m = new MyClassDeriveD(); 12 | m->foo(); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0023.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 3, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0024.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 4, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0025.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 5, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0026.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 7, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0027.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 7, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0028.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 7, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0029.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 9, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0042.cpp: -------------------------------------------------------------------------------- 1 | int main(int argc, char** argv) { 2 | const auto l = [](int a, int b) { 3 | float alpha = a / (1.0 * b); 4 | double delta = .0; 5 | for (int i = 0; i < 4; ++i) { 6 | delta = a * i * alpha; 7 | } 8 | return delta; 9 | }; 10 | auto d = l(2, 4); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0228.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_ZL17__uint16_identityt": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0242.cpp: -------------------------------------------------------------------------------- 1 | // Test for the handling of constructors and destructors when passing arguments 2 | struct A { 3 | ~A() {}; 4 | }; 5 | 6 | // Should not call destructors 7 | void foo(A a) {} 8 | 9 | // Needs to call destructor for A 10 | void boo(A& a) { foo(a); } 11 | 12 | int main() { 13 | A o; 14 | boo(o); 15 | } 16 | -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0053_b.cpp: -------------------------------------------------------------------------------- 1 | // call to redefining function 2 | 3 | #include "0053.h" 4 | 5 | class MyClassDeriveD : public MyClassDerive { 6 | public: 7 | int foo() { return 1; } 8 | }; 9 | 10 | int main(int argc, char* argv[]) { 11 | MyClass* m = new MyClassDeriveD(); 12 | m->foo(); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0048.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | get2(1)(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/inst-test/04_inline.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx clang++ %s -emit-llvm -S -o - | %filecheck %s 2 | 3 | inline int inlined_add(int x, int y) { return x + y; } 4 | 5 | void caller() { inlined_add(96, 4); } 6 | 7 | // CHECK: define linkonce_odr dso_local noundef i32 @_Z11inlined_addii( 8 | // CHECK: declare void @__metacg_indirect_call( 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build/ 3 | install/ 4 | extern/ 5 | .venv/ 6 | tools/cgpatch/test/pass-tests/*/Output 7 | tools/cgpatch/test/pass-tests/.lit_test_times.txt 8 | tools/cgpatch/test/pass-tests/vcall-detection-test/*.s 9 | 10 | 11 | .idea/ 12 | build* 13 | .cache/ 14 | cmake-build*/ 15 | 16 | # Spack 17 | spack.yaml 18 | spack.lock 19 | .spack-env/ 20 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0203.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void get_func2(func_t* out, func_t in) { 5 | *out = in; 6 | in(); 7 | } 8 | func_t get_func(func_t f) { 9 | func_t res; 10 | get_func2(&res, f); 11 | return res; 12 | } 13 | void foo() {} 14 | int main() { 15 | auto f = get_func(foo); 16 | f(); 17 | } 18 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0030.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 4 + 2; } 3 | 4 | int main(int argc, char** argv) { 5 | int k = 12; 6 | int i = foo(); 7 | 8 | while (i < k) { 9 | if (k % 2 == 0) { 10 | ++k; 11 | } else { 12 | ++i; 13 | ++k; 14 | } 15 | ++i; 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0035.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | case 2: 14 | default: 15 | k = 11; 16 | break; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0224.cpp: -------------------------------------------------------------------------------- 1 | int test2() { return 0; } 2 | 3 | int test() { 4 | do { 5 | return test2(); 6 | } while (true); 7 | }; 8 | 9 | int main() { 10 | while (true) { 11 | int a; 12 | while (true) { 13 | test(); 14 | break; 15 | } 16 | a = 0; 17 | break; 18 | } 19 | test(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0235.cpp: -------------------------------------------------------------------------------- 1 | // Tests passing function pointers as C++ style constructor init 2 | 3 | typedef void (*Function)(); 4 | 5 | void foo() {} 6 | 7 | class C { 8 | public: 9 | C(Function F) : member(F) {}; 10 | 11 | Function member; 12 | }; 13 | 14 | int main() { 15 | C a(&foo); 16 | Function b = a.member; 17 | b(); 18 | } -------------------------------------------------------------------------------- /graph/test/integration/CallgraphMerge/input/0053_both.cpp: -------------------------------------------------------------------------------- 1 | #include "0053.h" 2 | 3 | int MyClassDerive::foo() { return 42; } 4 | 5 | class MyClassDeriveD : public MyClassDerive { 6 | public: 7 | int foo() { return 1; } 8 | }; 9 | 10 | int main(int argc, char* argv[]) { 11 | MyClass* m = new MyClassDeriveD(); 12 | m->foo(); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0221.cpp: -------------------------------------------------------------------------------- 1 | // Test branch 2 | 3 | int main() { 4 | bool a = 5 ? false : true; 5 | int b = 7; 6 | if (a) { 7 | switch (b) { 8 | default: 9 | break; 10 | } 11 | } else if (b) { 12 | bool f = true; 13 | while (f) { 14 | f = false; 15 | } 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0051.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | Fn a = dflt; 10 | if (i == 1) 11 | return one; 12 | return a; 13 | } 14 | 15 | Fn get2(int i) { return get(i); } 16 | 17 | int main() { 18 | get2(1)(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0114.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handling of default arguments 2 | extern void foo(); 3 | extern void bar(); 4 | using FType = decltype(foo); 5 | 6 | void f(FType n, FType k); 7 | void f(FType n, FType k = bar); 8 | void f(FType n = foo, FType k); 9 | 10 | int main() { f(); } 11 | 12 | void f(FType n, FType k) { 13 | n(); 14 | k(); 15 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/allCtorDtor/0003.cpp: -------------------------------------------------------------------------------- 1 | // Member b of A is default-initialized, this must be caught by cgcollector. 2 | // This will lead to a callpath existing from A() through B() to hidden() 3 | 4 | void hidden() {} 5 | 6 | struct B { 7 | int* data; 8 | B() { hidden(); } 9 | }; 10 | 11 | struct A { 12 | A() {} 13 | 14 | B b; 15 | }; 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0203.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | void get_func2(func_t* out, func_t in) { 5 | *out = in; 6 | in(); 7 | } 8 | func_t get_func(func_t f) { 9 | func_t res; 10 | get_func2(&res, f); 11 | return res; 12 | } 13 | void foo() {} 14 | int main() { 15 | auto f = get_func(foo); 16 | f(); 17 | } 18 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0035.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | case 2: 14 | default: 15 | k = 11; 16 | break; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0242.cpp: -------------------------------------------------------------------------------- 1 | // Test for the handling of constructors and destructors when passing arguments 2 | struct A { 3 | ~A() {}; 4 | }; 5 | 6 | // Should not call destructors 7 | void foo(A a) {} 8 | 9 | // Needs to call destructor for A 10 | void boo(A& a) { foo(a); } 11 | 12 | int main() { 13 | A o; 14 | boo(o); 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0240_b.cpp: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | extern void bar(); 3 | using FType = decltype(foo); 4 | 5 | void f(FType n, FType k); 6 | void f(FType n, FType k = bar); 7 | void f(FType n = foo, FType k); 8 | 9 | void work(); 10 | 11 | int main() { 12 | work(); 13 | f(); 14 | } 15 | 16 | void f(FType n, FType k) { 17 | n(); 18 | k(); 19 | } -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/include/foo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File: foo.h 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | #ifndef METACG_TEST_FOO_H 8 | #define METACG_TEST_FOO_H 9 | 10 | void foo(); 11 | 12 | #endif // METACG_TEST_FOO_H 13 | -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/main.expected: -------------------------------------------------------------------------------- 1 | {"_Z3foov":{"callees":[],"doesOverride":false,"hasBody":false,"isVirtual":false,"numStatements":0,"overriddenBy":[],"overriddenFunctions":[],"parents":["main"]},"main":{"callees":["_Z3foov"],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":1,"overriddenBy":[],"overriddenFunctions":[],"parents":[]}} 2 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/001.c: -------------------------------------------------------------------------------- 1 | 2 | void foo() { 3 | // 1 stmt 4 | int a = 1 + 2; 5 | } 6 | 7 | void bar() { 8 | // 1 stmt 9 | int a = 1 + 2; 10 | } 11 | 12 | void hash() { 13 | // 1 stmt 14 | int a = 1 + 2; 15 | } 16 | 17 | void goo() { 18 | // 1 stmt 19 | int a = 1 + 2; 20 | } 21 | 22 | int main(int argc, char **argv) { return 0; } 23 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0051.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | Fn a = dflt; 10 | if (i == 1) 11 | return one; 12 | return a; 13 | } 14 | 15 | Fn get2(int i) { return get(i); } 16 | 17 | int main() { 18 | get2(1)(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0030.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo() { return 4 + 2; } 3 | 4 | int main(int argc, char** argv) { 5 | int k = 12; 6 | int i = foo(); 7 | 8 | while (i < k) { 9 | if (k % 2 == 0) { 10 | ++k; 11 | } else { 12 | ++i; 13 | ++k; 14 | } 15 | ++i; 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0042.cpp: -------------------------------------------------------------------------------- 1 | int main(int argc, char** argv) { 2 | const auto l = [](int a, int b) { 3 | float alpha = a / (1.0 * b); 4 | double delta = .0; 5 | for (int i = 0; i < 4; ++i) { 6 | delta = a * i * alpha; 7 | } 8 | return delta; 9 | }; 10 | auto d = l(2, 4); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0047.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | int (*f)() = get2(1); 18 | f(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0053.cpp: -------------------------------------------------------------------------------- 1 | // TODO Fix this for AA 2 | int main(int argc, char** argv) { 3 | const auto l = [](int a, int b) { 4 | float alpha = a / (1.0 * b); 5 | double delta = .0; 6 | for (int i = 0; i < 4; ++i) { 7 | delta = a * i * alpha; 8 | } 9 | return delta; 10 | }; 11 | auto d = l(2, 4); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0061.cpp: -------------------------------------------------------------------------------- 1 | // Tests assignment of structs and function pointer members 2 | extern void fooA(); 3 | 4 | typedef void (*Ftype)(); 5 | 6 | struct A { 7 | void* Member; 8 | }; 9 | 10 | int main() { 11 | struct A First; 12 | First.Member = (void*)&fooA; 13 | struct A Second = First; 14 | ((Ftype)Second.Member)(); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0069.cpp: -------------------------------------------------------------------------------- 1 | // This checks just that we can handle calls to variadic functions, not that their arguments are handled correctly 2 | 3 | extern int var_func(int a, int, int b, ...); 4 | 5 | int main() { 6 | int arga = 0; 7 | int argb = 0; 8 | int argc = 0; 9 | int argd = 0; 10 | var_func(arga, argb, argc, argd); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0241.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can pass function pointers with an -> member access 2 | 3 | extern int foo(); 4 | 5 | using FType = decltype(foo); 6 | 7 | struct Storage { 8 | FType* fptr; 9 | }; 10 | 11 | int main() { 12 | Storage s; 13 | s.fptr = &foo; 14 | auto sptr = &s; 15 | auto f = sptr->fptr; 16 | f(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/fix/0001.cpp: -------------------------------------------------------------------------------- 1 | int valid() { return 0; } 2 | 3 | int missedCallee() { return 0; } 4 | 5 | int missedCaller() { return 0; } 6 | 7 | int bidrectionalMiss() { return 0; } 8 | 9 | int main(int argc, char** argv) { 10 | valid(); 11 | missedCallee(); 12 | missedCaller(); 13 | bidrectionalMiss(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /graph/test/integration/TargetCollector/src/wholeProgramCG.expected: -------------------------------------------------------------------------------- 1 | {"_Z3foov":{"callees":[],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":0,"overriddenBy":[],"overriddenFunctions":[],"parents":["main"]},"main":{"callees":["_Z3foov"],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":1,"overriddenBy":[],"overriddenFunctions":[],"parents":[]}} -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0224.cpp: -------------------------------------------------------------------------------- 1 | int test2() { return 0; } 2 | 3 | int test() { 4 | do { 5 | return test2(); 6 | } while (true); 7 | }; 8 | 9 | int main() { 10 | while (true) { 11 | int a; 12 | while (true) { 13 | test(); 14 | break; 15 | } 16 | a = 0; 17 | break; 18 | } 19 | test(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0232.cpp: -------------------------------------------------------------------------------- 1 | // Test for the handling of new and delete and calling function pointers within them 2 | typedef void (*Fn)(); 3 | 4 | void func1() {} 5 | 6 | class X { 7 | public: 8 | Fn function; 9 | X(Fn arg) { function = arg; } 10 | ~X() { function(); } 11 | }; 12 | 13 | int main() { 14 | const auto f = new X(func1); 15 | delete f; 16 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0240_b.cpp: -------------------------------------------------------------------------------- 1 | extern void foo(); 2 | extern void bar(); 3 | using FType = decltype(foo); 4 | 5 | void f(FType n, FType k); 6 | void f(FType n, FType k = bar); 7 | void f(FType n = foo, FType k); 8 | 9 | void work(); 10 | 11 | int main() { 12 | work(); 13 | f(); 14 | } 15 | 16 | void f(FType n, FType k) { 17 | n(); 18 | k(); 19 | } 20 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0114.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handling of default arguments 2 | extern void foo(); 3 | extern void bar(); 4 | using FType = decltype(foo); 5 | 6 | void f(FType n, FType k); 7 | void f(FType n, FType k = bar); 8 | void f(FType n = foo, FType k); 9 | 10 | int main() { f(); } 11 | 12 | void f(FType n, FType k) { 13 | n(); 14 | k(); 15 | } 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0046.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | int (*f)() = get2(1); 18 | int a = f(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0052.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | Fn a; 10 | a = dflt; 11 | if (i == 1) { 12 | return one; 13 | } 14 | return a; 15 | } 16 | 17 | Fn get2(int i) { return get(i); } 18 | 19 | int main() { 20 | get2(1)(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/dynamic_run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | 8 | echo -e "Dynamic Selection\nRunning $binary" 9 | cubeTest="${testNo/ipcg/cubex}" 10 | cmd="${binary} --use-cs-instrumentation --out-dir $outDir ${PWD}/$testNo --cube ${PWD}/$cubeTest" 11 | echo $cmd 12 | $cmd 13 | 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0047.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | int (*f)() = get2(1); 18 | f(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tools/cgdiff/test/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( 2 | cgdifftests 3 | main.cpp 4 | TestGlobalMDDiff.cpp 5 | TestNodeDiff.cpp 6 | TestNodeSummary.cpp 7 | ) 8 | 9 | target_include_directories(cgdifftests PRIVATE ../../include) 10 | 11 | add_metacg(cgdifftests) 12 | add_googletest_libraries(cgdifftests) 13 | 14 | add_test(NAME cgdiff_unittests COMMAND cgdifftests) 15 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0031.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | while (i < k) { 12 | if (k % 2 == 0) { 13 | ++k; 14 | } else { 15 | ++i; 16 | ++k; 17 | } 18 | ++i; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0228.cpp: -------------------------------------------------------------------------------- 1 | // Test to make sure we do not mangle the name of this function wrong again 2 | // According to the LLVM discourse, this has internal linkage and as such both manglings 3 | // GCC's and Clang's are permissable. 4 | extern "C" { 5 | typedef unsigned short int __uint16_t; 6 | static __inline __uint16_t __uint16_identity(__uint16_t __x) { return __x; } 7 | } 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0046.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | if (i == 1) 10 | return one; 11 | return dflt; 12 | } 13 | 14 | Fn get2(int i) { return get(i); } 15 | 16 | int main() { 17 | int (*f)() = get2(1); 18 | int a = f(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0052.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int dflt() { return 42; } 5 | 6 | typedef int (*Fn)(); 7 | 8 | Fn get(int i) { 9 | Fn a; 10 | a = dflt; 11 | if (i == 1) { 12 | return one; 13 | } 14 | return a; 15 | } 16 | 17 | Fn get2(int i) { return get(i); } 18 | 19 | int main() { 20 | get2(1)(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0053.cpp: -------------------------------------------------------------------------------- 1 | // TODO Fix this for AA 2 | 3 | int main(int argc, char** argv) { 4 | const auto l = [](int a, int b) { 5 | float alpha = a / (1.0 * b); 6 | double delta = .0; 7 | for (int i = 0; i < 4; ++i) { 8 | delta = a * i * alpha; 9 | } 10 | return delta; 11 | }; 12 | auto d = l(2, 4); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0061.cpp: -------------------------------------------------------------------------------- 1 | // Tests assignment of structs and function pointer members 2 | extern void fooA(); 3 | 4 | typedef void (*Ftype)(); 5 | 6 | struct A { 7 | void* Member; 8 | }; 9 | 10 | int main() { 11 | struct A First; 12 | First.Member = (void*)&fooA; 13 | struct A Second = First; 14 | ((Ftype)Second.Member)(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0069.cpp: -------------------------------------------------------------------------------- 1 | // This checks just that we can handle calls to variadic functions, not that their arguments are handled correctly 2 | 3 | extern int var_func(int a, int, int b, ...); 4 | 5 | int main() { 6 | int arga = 0; 7 | int argb = 0; 8 | int argc = 0; 9 | int argd = 0; 10 | var_func(arga, argb, argc, argd); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0241.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can pass function pointers with an -> member access 2 | 3 | extern int foo(); 4 | 5 | using FType = decltype(foo); 6 | 7 | struct Storage { 8 | FType* fptr; 9 | }; 10 | 11 | int main() { 12 | Storage s; 13 | s.fptr = &foo; 14 | auto sptr = &s; 15 | auto f = sptr->fptr; 16 | f(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0072_b.cpp: -------------------------------------------------------------------------------- 1 | #define NULL 0 2 | 3 | void func1(); 4 | void func2(); 5 | 6 | void get_func_ptr(void (**func)(), int i) { 7 | void (*r)() = NULL; 8 | 9 | switch (i) { 10 | case 0: 11 | r = func1; 12 | break; 13 | default: 14 | r = func2; 15 | } 16 | 17 | *func = r; 18 | } 19 | 20 | void func1() {} 21 | 22 | void func2() {} 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0244.cpp: -------------------------------------------------------------------------------- 1 | // Test that code to va related builtins does not crash. This does not check correct behavior of these functions. 2 | void foo(const char* fmt, ...) { 3 | __builtin_va_list args; 4 | __builtin_va_start(args, fmt); 5 | __builtin_va_end(args); 6 | } 7 | 8 | int main() { 9 | const char* fmt = "Hello"; 10 | foo(fmt); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgpatch/test/integration/input/general/01_a.cpp: -------------------------------------------------------------------------------- 1 | template 2 | void foo(F& f) { 3 | f(); 4 | } 5 | 6 | template 7 | void foo_with_arg(F& f, int x) { 8 | f(x); 9 | } 10 | 11 | void bar() {} 12 | 13 | void bar_with_arg(int x) {} 14 | 15 | void caller(int x) { 16 | foo(bar); 17 | foo_with_arg(bar_with_arg, x); 18 | } 19 | 20 | int main() { caller(2); } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0209.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct A { 3 | void foo() {} 4 | void bar() {} 5 | void baz() {} 6 | }; 7 | using func_t = void (A::*)(); 8 | func_t get_f(bool b) { 9 | func_t fooPtr; 10 | fooPtr = &A::foo; 11 | if (b) { 12 | return &A::bar; 13 | } 14 | return fooPtr; 15 | } 16 | int main() { 17 | A a; 18 | auto f = get_f(1); 19 | (a.*f)(); 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0018.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: MemberFunctions.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | struct A { 8 | int foo() { return 6; } 9 | }; 10 | 11 | int main() { 12 | A a = A(); 13 | int r = a.foo(); 14 | return r; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0031.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | while (i < k) { 12 | if (k % 2 == 0) { 13 | ++k; 14 | } else { 15 | ++i; 16 | ++k; 17 | } 18 | ++i; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0072_b.cpp: -------------------------------------------------------------------------------- 1 | #define NULL 0 2 | 3 | void func1(); 4 | void func2(); 5 | 6 | void get_func_ptr(void (**func)(), int i) { 7 | void (*r)() = NULL; 8 | 9 | switch (i) { 10 | case 0: 11 | r = func1; 12 | break; 13 | default: 14 | r = func2; 15 | } 16 | 17 | *func = r; 18 | } 19 | 20 | void func1() {} 21 | 22 | void func2() {} 23 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0228.cpp: -------------------------------------------------------------------------------- 1 | // Test to make sure we do not mangle the name of this function wrong again 2 | // According to the LLVM discourse, this has internal linkage and as such both manglings 3 | // GCC's and Clang's are permissable. 4 | extern "C" { 5 | typedef unsigned short int __uint16_t; 6 | static __inline __uint16_t __uint16_identity(__uint16_t __x) { return __x; } 7 | } 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0244.cpp: -------------------------------------------------------------------------------- 1 | // Test that code to va related builtins does not crash. This does not check correct behavior of these functions. 2 | void foo(const char* fmt, ...) { 3 | __builtin_va_list args; 4 | __builtin_va_start(args, fmt); 5 | __builtin_va_end(args); 6 | } 7 | 8 | int main() { 9 | const char* fmt = "Hello"; 10 | foo(fmt); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /cgcollector/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PROJECT_NAME collector-tests) 2 | set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-target) 3 | 4 | configure_package_config_file( 5 | ${METACG_Directory}/cmake/Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake 6 | INSTALL_DESTINATION lib/cmake 7 | ) 8 | 9 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION lib/cmake) 10 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp3.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct A { 3 | virtual int foo() { return 42; } 4 | }; 5 | 6 | struct D : public A { 7 | virtual int foo() override { return 1; } 8 | }; 9 | 10 | struct Z : public D { 11 | virtual int foo() override { return 5; } 12 | }; 13 | 14 | void someFunc(A* a) { a->foo(); } 15 | 16 | int main() { 17 | Z z; 18 | someFunc(&z); 19 | } 20 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0008.cpp: -------------------------------------------------------------------------------- 1 | // call to overriding function 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass mc; 17 | MyClassDerive mcd; 18 | mcd.foo(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0009.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass mc; 17 | MyClassDerive mcd; 18 | mc.foo(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/imbalance_run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | 8 | echo -e "Load imbalance Selection\nRunning $binary" 9 | cubeTest="${testNo/ipcg/cubex}" 10 | cmd="${binary} --out-dir $outDir --cube ${PWD}/$cubeTest --parameter-file ${PWD}/parameters.json --lide --debug 1 ${PWD}/$testNo" 11 | echo $cmd 12 | $cmd 13 | 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0011.cpp: -------------------------------------------------------------------------------- 1 | // call to redefined function 2 | 3 | class MyClass {}; 4 | 5 | class MyClassDerive : public MyClass { 6 | public: 7 | int foo() { return 0; } 8 | }; 9 | 10 | class MyClassDeriveD : public MyClassDerive { 11 | public: 12 | int foo() { return 1; } 13 | }; 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDerive mcd; 17 | mcd.foo(); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0012.cpp: -------------------------------------------------------------------------------- 1 | // call to redefining function 2 | 3 | class MyClass {}; 4 | 5 | class MyClassDerive : public MyClass { 6 | public: 7 | int foo() { return 0; } 8 | }; 9 | 10 | class MyClassDeriveD : public MyClassDerive { 11 | public: 12 | int foo() { return 1; } 13 | }; 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDeriveD mcdd; 17 | mcdd.foo(); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/static_run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | if [ -z $4 ]; then 8 | scorepOut="" 9 | else 10 | scorepOut="--scorep-out" 11 | fi 12 | 13 | echo -e "Static Selection\nRunning $binary" 14 | cmd="${binary} ${scorepOut} --out-dir $outDir --use-cs-instrumentation --static ${PWD}/$testNo" 15 | echo $cmd 16 | $cmd 17 | 18 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0008.cpp: -------------------------------------------------------------------------------- 1 | // call to overriding function 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass mc; 17 | MyClassDerive mcd; 18 | mcd.foo(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0009.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass mc; 17 | MyClassDerive mcd; 18 | mc.foo(); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0041.cpp: -------------------------------------------------------------------------------- 1 | 2 | typedef void (*target_func_T)(int a, int b, int c); 3 | 4 | void callTarget(int a, int b, int c) { 5 | int d = a + b; 6 | d *= c; 7 | } 8 | 9 | void pointerCaller(target_func_T f, int a, int b, int c) { f(a, b, c); } 10 | 11 | int main(int argc, char** argv) { 12 | int a, b, c; 13 | a = b = c = 42; 14 | pointerCaller(callTarget, a, b, c); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/005.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unistd.h" 3 | 4 | int fooChild() { 5 | int a = 0; 6 | int b = 4; 7 | int c = 2; 8 | return (a * b) / c; 9 | } 10 | 11 | int foo() { 12 | sleep(10); 13 | fooChild(); 14 | return 0; 15 | } 16 | 17 | int bar() { 18 | sleep(1); 19 | return 0; 20 | } 21 | 22 | int main(int argc, char **argv) { 23 | int a = foo(); 24 | int b = bar(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "LIDe": { 3 | "metricType": "ImbalancePercentage", 4 | "imbalanceThreshold": 0.05, 5 | "relevanceThreshold": 0.1, 6 | "contextStrategy": "MajorPathsToMain", 7 | "contextStepCount": 5, 8 | "childRelevanceStrategy": "ConstantThreshold", 9 | "childConstantThreshold": 1, 10 | "childFraction": 0.5 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0008.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalStackStruct.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | struct localStruct { 8 | int operator()(int a, int b, int c) { return a + b * c; } 9 | }; 10 | int main() { 11 | auto c = localStruct(); 12 | return c(1, 2, 3); 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0011.cpp: -------------------------------------------------------------------------------- 1 | // call to redefined function 2 | 3 | class MyClass {}; 4 | 5 | class MyClassDerive : public MyClass { 6 | public: 7 | int foo() { return 0; } 8 | }; 9 | 10 | class MyClassDeriveD : public MyClassDerive { 11 | public: 12 | int foo() { return 1; } 13 | }; 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDerive mcd; 17 | mcd.foo(); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0012.cpp: -------------------------------------------------------------------------------- 1 | // call to redefining function 2 | 3 | class MyClass {}; 4 | 5 | class MyClassDerive : public MyClass { 6 | public: 7 | int foo() { return 0; } 8 | }; 9 | 10 | class MyClassDeriveD : public MyClassDerive { 11 | public: 12 | int foo() { return 1; } 13 | }; 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDeriveD mcdd; 17 | mcdd.foo(); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/edge_missing_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_basic.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgC_basic.mcg", 4 | "ignoring": [ 5 | "edges" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0016.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalStackStruct.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | struct localStruct { 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | auto c = localStruct(); 12 | return c(1, 2, 3); 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0041.cpp: -------------------------------------------------------------------------------- 1 | 2 | typedef void (*target_func_T)(int a, int b, int c); 3 | 4 | void callTarget(int a, int b, int c) { 5 | int d = a + b; 6 | d *= c; 7 | } 8 | 9 | void pointerCaller(target_func_T f, int a, int b, int c) { f(a, b, c); } 10 | 11 | int main(int argc, char** argv) { 12 | int a, b, c; 13 | a = b = c = 42; 14 | pointerCaller(callTarget, a, b, c); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0234.cpp.disabled: -------------------------------------------------------------------------------- 1 | // Tests an explicit destructor call 2 | // Disabled because ground truth does not contain ~X()'s call to func1 via function(); 3 | typedef void (*Fn)(); 4 | 5 | void func1() {} 6 | 7 | class X { 8 | public: 9 | Fn function; 10 | X(Fn arg) { function = arg; } 11 | ~X() { function(); } 12 | }; 13 | 14 | int main() { 15 | const auto f = new X(func1); 16 | f->~X(); 17 | } 18 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/body_different_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_basic.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgD_basic.mcg", 4 | "ignoring": [ 5 | "body" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/edge_different_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_basic.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgE_basic.mcg", 4 | "ignoring": [ 5 | "edges" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0230.cpp: -------------------------------------------------------------------------------- 1 | // Test for the handling of member functions and members that hold function pointers 2 | class A { 3 | public: 4 | void* member; 5 | void* memberFunction() { 6 | auto p = this; 7 | return member; 8 | } 9 | }; 10 | 11 | void f() {} 12 | typedef void (*Fn)(); 13 | 14 | int main() { 15 | A a; 16 | a.member = (void*)&f; 17 | Fn b = (Fn)a.memberFunction(); 18 | b(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0009.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalStackStructDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | struct localStruct { 8 | int operator()(int a, int b, int c) { return a + b * c; } 9 | }; 10 | int main() { 11 | auto c = localStruct()(1, 2, 3); 12 | return c; 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/metadata_missing_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_metadata.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_basic.mcg", 4 | "ignoring": [ 5 | "metadata" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0036.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | k = 2; 14 | break; 15 | case 4: 16 | k = 100; 17 | i = 101; 18 | break; 19 | default: 20 | k = 11; 21 | break; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0072_a.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Testcase for the multi TU imbalance integration test 3 | */ 4 | #define NULL 0 5 | 6 | void get_func_ptr(void (**func)(), int i); 7 | 8 | void function_pointer_test() { 9 | void (*r)() = NULL; 10 | 11 | get_func_ptr(&r, 0); 12 | 13 | r(); 14 | } 15 | 16 | /** 17 | * Main function 18 | */ 19 | int main(int argc, char** argv) { 20 | function_pointer_test(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0245.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can call a function and take the address of its return value 2 | // Note the ground truth here contains some wrong edges, but this is caused by the traditional CG construction 3 | 4 | int a; 5 | 6 | class error_code { 7 | public: 8 | const int& category() const noexcept { return a; } 9 | }; 10 | 11 | void foo(const error_code& __e) { (void*)&(__e.category()); } 12 | 13 | int main() {} 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0003.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalHeapStruct.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | struct localStruct { 8 | int operator()(int a, int b, int c) { return a + b * c; } 9 | }; 10 | int main() { 11 | auto* c = new localStruct(); 12 | return c->operator()(1, 2, 3); 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0006.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalStackClass.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | class localClass { 8 | public: 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | 12 | int main() { 13 | auto c = localClass(); 14 | return c(1, 2, 3); 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0014.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalStackClass.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | class localClass { 9 | public: 10 | int operator()(int a, int b, int c) { return a + b * c; } 11 | }; 12 | auto c = localClass(); 13 | return c(1, 2, 3); 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0017.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalStackStructDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | struct localStruct { 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | auto c = localStruct()(1, 2, 3); 12 | return c; 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0235.cpp.disabled: -------------------------------------------------------------------------------- 1 | // Tests passing function pointers as C++ style constructor init 2 | // Disabled because ground truth call graph does not contain a call from main to foo via b(); 3 | 4 | typedef void (*Function)(); 5 | 6 | void foo() {} 7 | 8 | class C { 9 | public: 10 | C(Function F) : member(F){}; 11 | 12 | Function member; 13 | }; 14 | 15 | int main() { C a(&foo); Function b = a.member; b(); } 16 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/metadata_different_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_metadata.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgB_metadata.mcg", 4 | "ignoring": [ 5 | "metadata" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0062.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handing of functions with different but compatible definitions 2 | void foo(int n) { int var = n; } 3 | typedef void (*Ftype)(int); 4 | 5 | void baa(Ftype f, int n, int, int arg); 6 | 7 | int main() { 8 | Ftype f = &foo; 9 | int arg = 5; 10 | int arg2 = 6; 11 | int arg3 = 7; 12 | baa(f, arg, arg2, arg3); 13 | return 0; 14 | } 15 | 16 | void baa(Ftype f, int n, int a, int b) { f(n + a + b); } -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0243.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can pass parameters to function that are defined with __typeof. The problem here is that the 2 | // RecursiveASTVisitor is not visiting their parameters 3 | namespace test_cxx { 4 | extern "C" bool uselocale2(bool); 5 | extern "C" __typeof(uselocale2) __uselocale2; 6 | 7 | } // namespace test_cxx 8 | 9 | int main() { 10 | bool i = false; 11 | test_cxx::__uselocale2(i); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /pgis/test/integration/inputdynamic/dynamic_run_v2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | 8 | echo -e "Dynamic Selection\nRunning $binary" 9 | echo -e "For now skipping MetaCG file format 2 test" 10 | cubeTest="${testNo/mcg/cubex}" 11 | cmd="${binary} --use-cs-instrumentation --metacg-format 2 --out-dir $outDir ${PWD}/$testNo --cube ${PWD}/$cubeTest" 12 | echo $cmd 13 | $cmd 14 | 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0007.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalStackCallDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | class localClass { 8 | public: 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | int main() { 12 | auto c = localClass()(1, 2, 3); 13 | return c; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0012.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalHeapStruct.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | struct localStruct { 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | auto* c = new localStruct(); 12 | return c->operator()(1, 2, 3); 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0036.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | k = 2; 14 | break; 15 | case 4: 16 | k = 100; 17 | i = 101; 18 | break; 19 | default: 20 | k = 11; 21 | break; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/multiTU/0072_a.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Testcase for the multi TU imbalance integration test 3 | */ 4 | #define NULL 0 5 | 6 | void get_func_ptr(void (**func)(), int i); 7 | 8 | void function_pointer_test() { 9 | void (*r)() = NULL; 10 | 11 | get_func_ptr(&r, 0); 12 | 13 | r(); 14 | } 15 | 16 | /** 17 | * Main function 18 | */ 19 | int main(int argc, char** argv) { 20 | function_pointer_test(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0040.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | k = 2; 14 | break; 15 | case 4: { 16 | k = 100; 17 | i = 101; 18 | break; 19 | } 20 | default: 21 | k = 11; 22 | break; 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/001.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unistd.h" 3 | 4 | #ifndef X 5 | #define X 2 6 | #endif 7 | 8 | #ifndef Y 9 | #define Y 4 10 | #endif 11 | 12 | int fooChild() { return 42; } 13 | 14 | int foo() { 15 | sleep(X); 16 | return fooChild() * 3; 17 | } 18 | 19 | int bar() { 20 | sleep(Y); 21 | return 2; 22 | } 23 | 24 | int main(int argc, char **argv) { 25 | int a = foo(); 26 | int b = bar(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0013.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalHeapStructDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | int main() { 7 | struct localStruct { 8 | int operator()(int a, int b, int c) { return a + b * c; } 9 | }; 10 | auto c = (new localStruct())->operator()(1, 2, 3); 11 | return c; 12 | } 13 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0015.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalStackClassDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | class localClass { 9 | public: 10 | int operator()(int a, int b, int c) { return a + b * c; } 11 | }; 12 | auto c = localClass()(1, 2, 3); 13 | return c; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0230.cpp: -------------------------------------------------------------------------------- 1 | // Test for the handling of member functions and members that hold function pointers 2 | class A { 3 | public: 4 | void* member; 5 | void* memberFunction() { 6 | auto p = this; 7 | return member; 8 | } 9 | }; 10 | 11 | void f() {} 12 | typedef void (*Fn)(); 13 | 14 | int main() { 15 | A a; 16 | a.member = (void*)&f; 17 | Fn b = (Fn)a.memberFunction(); 18 | b(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0245.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can call a function and take the address of its return value 2 | // Note the ground truth here contains some wrong edges, but this is caused by the traditional CG construction 3 | 4 | int a; 5 | 6 | class error_code { 7 | public: 8 | const int& category() const noexcept { return a; } 9 | }; 10 | 11 | void foo(const error_code& __e) { (void*)&(__e.category()); } 12 | 13 | int main() {} 14 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/global_md_different_flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_global_md.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgB_global_md.mcg", 4 | "ignoring": [ 5 | "global-metadata" 6 | ], 7 | "diff": { 8 | "nodeDiffs": {}, 9 | "globalMetaDiff": {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cgcollector/lib/include/Utils.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef METACG_CGCOLLECTOR_UTILS_H 3 | #define METACG_CGCOLLECTOR_UTILS_H 4 | 5 | #include 6 | 7 | const clang::Type* resolveToUnderlyingType(const clang::Type* ty) { 8 | if (!ty->isPointerType()) { 9 | return ty; 10 | // std::cout << "resolveToUnderlyingType: isPointerType" << std::endl; 11 | } 12 | return resolveToUnderlyingType(ty->getPointeeType().getTypePtr()); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0019.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of base class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass* mc; 17 | MyClassDerive mcd; 18 | mc = &mcd; 19 | mc->foo(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/static_run_v2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | 8 | if [ -z "$4" ]; then 9 | scorepOut="" 10 | else 11 | scorepOut="--scorep-out" 12 | fi 13 | 14 | echo -e "Static Selection\nRunning $binary" 15 | cmd="${binary} ${scorepOut} --metacg-format 2 --out-dir $outDir --use-cs-instrumentation --static ${PWD}/$testNo" 16 | echo $cmd 17 | $cmd 18 | 19 | 20 | -------------------------------------------------------------------------------- /tools/cgcollector2/fileInfoDemoPlugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(FileInfoPlugin SHARED FileInfoMetadata.cpp FileInfoMetadataPlugin.cpp) 2 | add_clang(FileInfoPlugin) 3 | add_graph_includes(FileInfoPlugin) 4 | add_spdlog_libraries(FileInfoPlugin) 5 | add_json(FileInfoPlugin) 6 | target_include_directories(FileInfoPlugin PUBLIC $) 7 | set_target_properties(FileInfoPlugin PROPERTIES PREFIX "" SUFFIX ".collector") 8 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0001.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalHeapClass.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | class localClass { 8 | public: 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | int main() { 12 | localClass* c = new localClass(); 13 | return c->operator()(1, 2, 3); 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0004.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalHeapStructDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | struct localStruct { 8 | int operator()(int a, int b, int c) { return a + b * c; } 9 | }; 10 | 11 | int main() { 12 | auto c = (new localStruct())->operator()(1, 2, 3); 13 | return c; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0243.cpp: -------------------------------------------------------------------------------- 1 | // Test that we can pass parameters to function that are defined with __typeof. The problem here is that the 2 | // RecursiveASTVisitor is not visiting their parameters 3 | namespace test_cxx { 4 | extern "C" bool uselocale2(bool); 5 | extern "C" __typeof(uselocale2) __uselocale2; 6 | 7 | } // namespace test_cxx 8 | 9 | int main() { 10 | bool i = false; 11 | test_cxx::__uselocale2(i); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /tools/cgdiff/README.md: -------------------------------------------------------------------------------- 1 | # CGDiff 2 | 3 | CGDiff compares to MetaCG call-graphs. The comparison is based on features such as name, hasBody, callees, metadata. 4 | 5 | **NOTE:** Since nodeIDs are not unique across call graphs, the node name is used as the unique identifier. 6 | 7 | ### Usage 8 | 9 | ``` 10 | 11 | ./cgdiff [options] 12 | 13 | ``` 14 | 15 | **Example:** `./cgdiff ./input/cgA_basic.mcg ./input/cgC_basic.mcg --ignore-edges` 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0040.cpp: -------------------------------------------------------------------------------- 1 | 2 | int foo(int k) { 3 | ++k; 4 | return 4 * k; 5 | } 6 | 7 | int main(int argc, char** argv) { 8 | int k = 12; 9 | int i = foo(k); 10 | 11 | switch (k) { 12 | case 1: 13 | k = 2; 14 | break; 15 | case 4: { 16 | k = 100; 17 | i = 101; 18 | break; 19 | } 20 | default: 21 | k = 11; 22 | break; 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0062.cpp: -------------------------------------------------------------------------------- 1 | // Tests the handing of functions with different but compatible definitions 2 | void foo(int n) { int var = n; } 3 | typedef void (*Ftype)(int); 4 | 5 | void baa(Ftype f, int n, int, int arg); 6 | 7 | int main() { 8 | Ftype f = &foo; 9 | int arg = 5; 10 | int arg2 = 6; 11 | int arg3 = 7; 12 | baa(f, arg, arg2, arg3); 13 | return 0; 14 | } 15 | 16 | void baa(Ftype f, int n, int a, int b) { f(n + a + b); } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0020.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of current class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDerive* mc; 17 | MyClassDerive mcd; 18 | mc = &mcd; 19 | mc->foo(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cmake/GoogleTest.cmake: -------------------------------------------------------------------------------- 1 | include(FetchContent) 2 | FetchContent_Declare( 3 | googletest URL https://github.com/google/googletest/releases/download/v1.17.0/googletest-1.17.0.tar.gz 4 | ) 5 | FetchContent_MakeAvailable(googletest) 6 | 7 | set(gtest_force_shared_crt 8 | ON 9 | CACHE BOOL 10 | "" 11 | FORCE 12 | ) 13 | 14 | function(add_googletest_libraries target) 15 | target_link_libraries(${target} PUBLIC GTest::gtest_main) 16 | endfunction() 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0002.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalHeapClassDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | class localClass { 8 | public: 9 | int operator()(int a, int b, int c) { return a + b * c; } 10 | }; 11 | 12 | int main() { 13 | auto c = (new localClass())->operator()(1, 2, 3); 14 | return c; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0010.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalHeapClass.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | class localClass { 9 | public: 10 | int operator()(int a, int b, int c) { return a + b * c; } 11 | }; 12 | localClass* c = new localClass(); 13 | return c->operator()(1, 2, 3); 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0019.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of base class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClass* mc; 17 | MyClassDerive mcd; 18 | mc = &mcd; 19 | mc->foo(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/formatAllSrc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | find ./lib -iname "*.h" -not -type d -exec clang-format -i {} \; 4 | find ./lib -iname "*.cpp" -not -type d -exec clang-format -i {} \; 5 | find ./tools -iname "*.h" -not -type d -exec clang-format -i {} \; 6 | find ./tools -iname "*.cpp" -not -type d -exec clang-format -i {} \; 7 | find ./test -iname "*.h" -not -type d -exec clang-format -i {} \; 8 | find ./test -iname "*.cpp" -not -type d -exec clang-format -i {} \; 9 | 10 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0237.cpp: -------------------------------------------------------------------------------- 1 | // Tests for c++ style constructor init 2 | int foo(); 3 | int boo(); 4 | using FType = decltype(foo); 5 | 6 | class B { 7 | public: 8 | B(FType* arg) { f1 = arg; }; 9 | FType* f1; 10 | }; 11 | 12 | class C : B { 13 | public: 14 | C(FType* arg1, FType* arg2) : B(arg1), f2(arg2) {} 15 | FType* f2; 16 | void work() { 17 | f1(); 18 | f2(); 19 | } 20 | }; 21 | 22 | int main() { 23 | C c(foo, boo); 24 | c.work(); 25 | } -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0011.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: LocalHeapClassDirectCall.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | int main() { 8 | class localClass { 9 | public: 10 | int operator()(int a, int b, int c) { return a + b * c; } 11 | }; 12 | auto c = (new localClass())->operator()(1, 2, 3); 13 | return c; 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgpatch/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PROJECT_NAME collector-tests) 2 | set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-target) 3 | 4 | configure_package_config_file( 5 | ${METACG_Directory}/cmake/Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake 6 | INSTALL_DESTINATION lib/cmake 7 | ) 8 | 9 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION lib/cmake) 10 | 11 | add_subdirectory(pass-tests) 12 | add_subdirectory(integration) 13 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0045.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int two() { return 2; } 5 | 6 | int three() { return 3; } 7 | 8 | int dflt() { return 42; } 9 | 10 | typedef int (*Fn)(); 11 | 12 | Fn get(int i) { 13 | if (i == 1) 14 | return one; 15 | if (i == 2) 16 | return two; 17 | if (i == 3) 18 | return three; 19 | return dflt; 20 | } 21 | 22 | int main() { 23 | int (*f)() = get(1); 24 | int a = f(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /cmake/CubeLib.cmake: -------------------------------------------------------------------------------- 1 | # Cube library installation 2 | find_library(CUBE_LIB cube4 PATHS ${CUBE_DIR}/lib REQUIRED) 3 | find_path(CUBE_INCLUDE Cube.h PATHS ${CUBE_DIR}/include/cubelib REQUIRED) 4 | 5 | message(STATUS "Using cubelib: ${CUBE_LIB}") 6 | message(STATUS "Using cube headers: ${CUBE_INCLUDE}") 7 | 8 | function(add_cube target) 9 | target_include_directories(${target} SYSTEM PUBLIC ${CUBE_INCLUDE}) 10 | target_link_libraries(${target} PUBLIC ${CUBE_LIB}) 11 | endfunction() 12 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0020.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of current class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | void MyClassDerive::foo() {} 14 | 15 | int main(int argc, char* argv[]) { 16 | MyClassDerive* mc; 17 | MyClassDerive mcd; 18 | mc = &mcd; 19 | mc->foo(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/09_lambda.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | int main() { 6 | auto lambda = []() { std::cout << "Lambda called" << std::endl; }; 7 | 8 | void (*funcPtr)() = lambda; 9 | 10 | // CHECK: Traversing function: main 11 | // CHECK-NOT: Virtual call identified 12 | // CHECK: Call is other indirect call 13 | funcPtr(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0232.cpp.disabled: -------------------------------------------------------------------------------- 1 | // Test for the handling of new and delete and calling function pointers within them 2 | // Disabled because ground truth does not contain ~X()'s call to func1 via function() 3 | typedef void (*Fn)(); 4 | 5 | void func1() {} 6 | 7 | class X { 8 | public: 9 | Fn function; 10 | X(Fn arg) { function = arg; } 11 | ~X() { function(); } 12 | }; 13 | 14 | int main() { 15 | const auto f = new X(func1); 16 | delete f; 17 | } 18 | -------------------------------------------------------------------------------- /cmake/ExtraP.cmake: -------------------------------------------------------------------------------- 1 | # Extra-P installation directory for library 2 | find_library(EXTRAP_LIB extrap) 3 | # Extra-P source tree for includes (they are not installed with extra-p) 4 | find_path(EXTRAP_INCLUDE extrap) 5 | 6 | function(add_extrap target) 7 | target_include_directories(${target} SYSTEM PUBLIC ${EXTRAP_INCLUDE}) 8 | target_link_directories( 9 | ${target} 10 | PUBLIC 11 | ${EXTRAP_LIB} 12 | ) 13 | target_link_libraries(${target} PUBLIC extrap) 14 | endfunction() 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0045.cpp: -------------------------------------------------------------------------------- 1 | 2 | int one() { return 1; } 3 | 4 | int two() { return 2; } 5 | 6 | int three() { return 3; } 7 | 8 | int dflt() { return 42; } 9 | 10 | typedef int (*Fn)(); 11 | 12 | Fn get(int i) { 13 | if (i == 1) 14 | return one; 15 | if (i == 2) 16 | return two; 17 | if (i == 3) 18 | return three; 19 | return dflt; 20 | } 21 | 22 | int main() { 23 | int (*f)() = get(1); 24 | int a = f(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0218.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: UnknownFunctionParams.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | typedef void (*FuncT)(); 8 | 9 | void libraryFunction(FuncT f, int param1, int param2); 10 | 11 | void foo() { 12 | // passed to lib 13 | } 14 | 15 | int main() { 16 | libraryFunction(foo, 5, 2); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /container/build_base_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Building the container base image is not possible on Lichtenberg due to a permission issue 4 | # with Podman. Thus, we build a base image on another machine, which is then downloaded and used 5 | # by the CI 6 | 7 | docker login registry.git.rwth-aachen.de 8 | docker build -t registry.git.rwth-aachen.de/tuda-sc/projects/metacg/base:latest -f container/base . 9 | docker push registry.git.rwth-aachen.de/tuda-sc/projects/metacg/base:latest 10 | -------------------------------------------------------------------------------- /pgis/test/integration/inputimbalance/imbalance_run_v2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | buildDir=$1 4 | outDir=$2 5 | testNo=$3 6 | binary=${buildDir}/tool/pgis_pira 7 | 8 | echo -e "Load imbalance Selection\nRunning $binary" 9 | echo -e "For now skipping MetaCG file format 2 test" 10 | cubeTest="${testNo/mcg/cubex}" 11 | cmd="${binary} --metacg-format 2 --out-dir $outDir --cube ${PWD}/$cubeTest --parameter-file ${PWD}/parameters.json --lide --debug 1 ${PWD}/$testNo" 12 | echo $cmd 13 | $cmd 14 | 15 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/10_fake_vcall_2.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | typedef void (**fake_vtable_t)(); 4 | 5 | extern fake_vtable_t get_fake_vtable(); 6 | 7 | int main() { 8 | auto fake_vtable = get_fake_vtable(); 9 | fake_vtable[0](); 10 | 11 | // CHECK: Traversing function: main 12 | // CHECK-NOT: Virtual call identified 13 | // CHECK: Call is other indirect call 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /pgis/test/integration/inputmodeling/002.c: -------------------------------------------------------------------------------- 1 | 2 | #include "unistd.h" 3 | 4 | #ifndef X 5 | #define X 2 6 | #endif 7 | 8 | #ifndef Y 9 | #define Y 4 10 | #endif 11 | 12 | int fooChild() { return 42; } 13 | 14 | int foo() { 15 | for (int i = 0; i < X; ++i) { 16 | sleep(Y); 17 | } 18 | return fooChild() * 3; 19 | } 20 | 21 | int bar() { 22 | sleep(Y); 23 | return 2; 24 | } 25 | 26 | int main(int argc, char **argv) { 27 | int a = foo(); 28 | int b = bar(); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /pymetacg/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(spdlog) 2 | include(json) 3 | 4 | enable_testing() 5 | 6 | find_package( 7 | Pytest 8 | 8.2.1 9 | REQUIRED 10 | ) 11 | 12 | add_library(dummy_md SHARED DummyMD.cpp) 13 | add_metacg(dummy_md) 14 | 15 | pytest_discover_tests( 16 | pymetacg_tests 17 | PYTHON_PATH_PREPEND 18 | $ 19 | ENVIRONMENT 20 | LD_PRELOAD=$ 21 | TRIM_FROM_NAME 22 | "^test_" 23 | DEPENDS 24 | pymetacg 25 | dummy_md 26 | ) 27 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0237.cpp.disabled: -------------------------------------------------------------------------------- 1 | // Tests for c++ style constructor init 2 | int foo(); 3 | int boo(); 4 | using FType = decltype(foo); 5 | 6 | class B { 7 | public: 8 | B(FType *arg) { f1 = arg; }; 9 | FType *f1; 10 | }; 11 | 12 | class C : B {0237 13 | public: 14 | C(FType *arg1, FType *arg2) : B(arg1), f2(arg2) {} 15 | FType *f2; 16 | void work() { 17 | f1(); 18 | f2(); 19 | } 20 | }; 21 | 22 | int main() { 23 | C c(foo, boo); 24 | c.work(); 25 | } 26 | -------------------------------------------------------------------------------- /tools/cgdiff/include/Diff.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File: Diff.h 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | #pragma once 7 | #include "nlohmann/json.hpp" 8 | 9 | namespace metacg { 10 | struct Diff { 11 | enum class Kind { Node, GlobalMD }; 12 | virtual ~Diff() = default; 13 | virtual Kind kind() const = 0; 14 | virtual nlohmann::ordered_json toJson() const = 0; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0016.cpp: -------------------------------------------------------------------------------- 1 | // override multiple functions 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClass2 { 9 | public: 10 | virtual void foo() {} 11 | }; 12 | 13 | class MyClassDerive : public MyClass, public MyClass2 { 14 | public: 15 | void foo() override; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClass mc; 22 | MyClassDerive mcd; 23 | mc.foo(); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/02_pointer_call.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | void foo() { std::cout << "A::foo()" << std::endl; } 6 | 7 | extern "C" void call_ptr(void (*ptr)()) { 8 | // CHECK: Traversing function: call_ptr 9 | // CHECK-NOT: Virtual call identified 10 | // CHECK: Call is other indirect call 11 | ptr(); 12 | } 13 | 14 | int main() { 15 | call_ptr(foo); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /graph/include/metadata/CustomMD.h.in: -------------------------------------------------------------------------------- 1 | /** 2 | * File: customMD.h 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | #ifndef METACG_CUSTOM_MD_H 7 | #define METACG_CUSTOM_MD_H 8 | 9 | // This file is auto-generated by CMake. Do not modify directly! 10 | // To include custom metadata, place the corresponding header files in `metadata/custom`. 11 | 12 | @INCLUDE_DIRECTIVES@ 13 | 14 | #endif // METACG_CUSTOM_MD_H 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0016.cpp: -------------------------------------------------------------------------------- 1 | // override multiple functions 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClass2 { 9 | public: 10 | virtual void foo() {} 11 | }; 12 | 13 | class MyClassDerive : public MyClass, public MyClass2 { 14 | public: 15 | void foo() override; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClass mc; 22 | MyClassDerive mcd; 23 | mc.foo(); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0065.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Testcase for a missing call in the load imbalance integration test 3 | */ 4 | 5 | typedef void (*Fn)(); 6 | 7 | void func1() {} 8 | 9 | void func2() {} 10 | 11 | Fn get_func_ptr(int i) { 12 | if (i == 0) { 13 | return func1; 14 | } else { 15 | return func2; 16 | } 17 | } 18 | 19 | /** 20 | * Main function 21 | */ 22 | int main(int argc, char** argv) { 23 | // function pointer test 24 | Fn func = get_func_ptr(0); 25 | func(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/base.sh: -------------------------------------------------------------------------------- 1 | function report { 2 | echo -e "\n[ --------------------------------- ] \n" >> "$logFile" 3 | echo "Running cgvalidate Integration Test $testNo | $failStr" 4 | } 5 | 6 | function failed { 7 | fails=$(($fails+1)) 8 | failStr=FAIL 9 | report 10 | } 11 | 12 | function passed { 13 | failStr=PASS 14 | report 15 | } 16 | 17 | function checkErrorCode { 18 | if [ $? -ne $1 ]; then 19 | failed 20 | else 21 | passed 22 | fi 23 | testNo=$(($testNo+1)) 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0065.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Testcase for a missing call in the load imbalance integration test 3 | */ 4 | 5 | typedef void (*Fn)(); 6 | 7 | void func1() {} 8 | 9 | void func2() {} 10 | 11 | Fn get_func_ptr(int i) { 12 | if (i == 0) { 13 | return func1; 14 | } else { 15 | return func2; 16 | } 17 | } 18 | 19 | /** 20 | * Main function 21 | */ 22 | int main(int argc, char** argv) { 23 | // function pointer test 24 | Fn func = get_func_ptr(0); 25 | func(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /graph/test/install/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project( 4 | MetaCG-Test-User 5 | VERSION 0.1 6 | DESCRIPTION "An annotatable whole-program call-graph toolset" 7 | ) 8 | 9 | find_package(metacg REQUIRED) 10 | 11 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 12 | set(CMAKE_VERBOSE_MAKEFILE ON) 13 | 14 | set(CMAKE_CXX_STANDARD 17) 15 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 16 | set(CMAKE_CXX_EXTENSIONS OFF) 17 | 18 | add_executable(mainprog main.cpp) 19 | 20 | target_link_libraries(mainprog metacg::metacg) 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0015.cpp: -------------------------------------------------------------------------------- 1 | // 2 overrides in a row 2 | // but no multiple inheritanc 3 | 4 | class MyClass { 5 | public: 6 | virtual void foo() {} 7 | }; 8 | 9 | class MyClass2 : public MyClass { 10 | public: 11 | virtual void foo() override {} 12 | }; 13 | 14 | class MyClassDerive : public MyClass2 { 15 | public: 16 | void foo() override; 17 | }; 18 | 19 | void MyClassDerive::foo() {} 20 | 21 | int main(int argc, char* argv[]) { 22 | MyClass mc; 23 | MyClassDerive mcd; 24 | mc.foo(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/08_call_in_dtor.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | struct A { 6 | virtual ~A() { 7 | // CHECK: Virtual call identified 8 | foo(); 9 | } 10 | virtual void foo() { std::cout << "A::foo()" << std::endl; } 11 | }; 12 | 13 | struct B : public A { 14 | void foo() override { std::cout << "B::foo()" << std::endl; } 15 | }; 16 | 17 | int main() { 18 | A* a = new B(); 19 | delete a; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0001.cpp_disabled: -------------------------------------------------------------------------------- 1 | /** 2 | * File: AllTheHeaderFiles.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | //This test is currently disabled as the math.h include differs between systems 8 | 9 | #include "math.h" 10 | 11 | int main() { 12 | int (*a)(int, int) = nullptr; 13 | double (*b)(double, double) = nullptr; 14 | double (*c)(double) = nullptr; 15 | return b(c(2.0), 4.0); 16 | } 17 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0015.cpp: -------------------------------------------------------------------------------- 1 | // 2 overrides in a row 2 | // but no multiple inheritanc 3 | 4 | class MyClass { 5 | public: 6 | virtual void foo() {} 7 | }; 8 | 9 | class MyClass2 : public MyClass { 10 | public: 11 | virtual void foo() override {} 12 | }; 13 | 14 | class MyClassDerive : public MyClass2 { 15 | public: 16 | void foo() override; 17 | }; 18 | 19 | void MyClassDerive::foo() {} 20 | 21 | int main(int argc, char* argv[]) { 22 | MyClass mc; 23 | MyClassDerive mcd; 24 | mc.foo(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0032.cpp: -------------------------------------------------------------------------------- 1 | 2 | int bar(int f) { 3 | int k = f % 3; 4 | int n = 0; 5 | while (k > 0) { 6 | --k; 7 | ++n; 8 | } 9 | return n; 10 | } 11 | 12 | int foo(int k) { 13 | ++k; 14 | return 4 * k; 15 | } 16 | 17 | int main(int argc, char** argv) { 18 | int k = 12; 19 | int i = foo(k); 20 | 21 | while (i < k) { 22 | if (k % 2 == 0) { 23 | ++k; 24 | } else { 25 | ++i; 26 | ++k; 27 | } 28 | ++i; 29 | } 30 | 31 | int n = bar(i); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp2.ipcg: -------------------------------------------------------------------------------- 1 | {"_Z8someFuncP1D":{"callees":["_ZN1A3fooEv"],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":1,"overriddenBy":[],"overriddenFunctions":[],"parents":["main"]},"_ZN1A3fooEv":{"callees":[],"doesOverride":false,"hasBody":true,"isVirtual":true,"numStatements":1,"overriddenBy":[],"overriddenFunctions":[],"parents":["_Z8someFuncP1D"]},"main":{"callees":["_Z8someFuncP1D"],"doesOverride":false,"hasBody":true,"isVirtual":false,"numStatements":2,"overriddenBy":[],"overriddenFunctions":[],"parents":[]}} 2 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0018.cpp: -------------------------------------------------------------------------------- 1 | // inheritance circle 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClass2 : public MyClass { 9 | public: 10 | virtual void foo() override {} // TODO core cump if override is missing 11 | }; 12 | 13 | class MyClassDerive : public MyClass, public MyClass2 { 14 | public: 15 | void foo() override; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClass mc; 22 | MyClassDerive mcd; 23 | mc.foo(); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/cxxRecordCalls/0005.cpp_disabled: -------------------------------------------------------------------------------- 1 | /** 2 | * File: GlobalLambda.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | //TODO: This test is currently disabled, as lambda parameter lists contain a full path to the definition 8 | // which differs from system to system 9 | 10 | auto globalLambda = [](int a, int b, int c) { return a + b + c; }; 11 | 12 | int main() { 13 | auto c = globalLambda; 14 | return c(1, 2, 3); 15 | } 16 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/metaCollectors/numStatements/0032.cpp: -------------------------------------------------------------------------------- 1 | 2 | int bar(int f) { 3 | int k = f % 3; 4 | int n = 0; 5 | while (k > 0) { 6 | --k; 7 | ++n; 8 | } 9 | return n; 10 | } 11 | 12 | int foo(int k) { 13 | ++k; 14 | return 4 * k; 15 | } 16 | 17 | int main(int argc, char** argv) { 18 | int k = 12; 19 | int i = foo(k); 20 | 21 | while (i < k) { 22 | if (k % 2 == 0) { 23 | ++k; 24 | } else { 25 | ++i; 26 | ++k; 27 | } 28 | ++i; 29 | } 30 | 31 | int n = bar(i); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTUAA/0067.cpp: -------------------------------------------------------------------------------- 1 | // Test for the alias analysis to check that it can generate unique USRs when macros are involved 2 | int foo(int a) { return 5 + a; } 3 | 4 | #define TWICE(a) \ 5 | foo(a); \ 6 | foo(a + 1); 7 | 8 | #define MY_MAX(a, b) (((a) < (b)) ? (b) : (a)) 9 | 10 | int main() { 11 | TWICE(5); 12 | return MY_MAX(8, foo(2)); 13 | } -------------------------------------------------------------------------------- /tools/cgpatch/test/integration/input/mpi/001_a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int secret(int x) { return x * 42; } 3 | 4 | int foo(int x) { return x * x; } 5 | 6 | int main(int argc, char** argv) { 7 | MPI_Init(&argc, &argv); 8 | 9 | int rank; 10 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 11 | 12 | if (rank == 1) { 13 | if (argc == 1) { 14 | void* vp = reinterpret_cast(&secret); 15 | int (*fptr)(int) = reinterpret_cast(vp); 16 | 17 | int result = fptr(7); 18 | } 19 | } 20 | 21 | MPI_Finalize(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0018.cpp: -------------------------------------------------------------------------------- 1 | // inheritance circle 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClass2 : public MyClass { 9 | public: 10 | virtual void foo() override {} // TODO core cump if override is missing 11 | }; 12 | 13 | class MyClassDerive : public MyClass, public MyClass2 { 14 | public: 15 | void foo() override; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClass mc; 22 | MyClassDerive mcd; 23 | mc.foo(); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tools/cgdiff/test/integration/groundtruthes/global_md_different.json: -------------------------------------------------------------------------------- 1 | { 2 | "cgA": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgA_global_md.mcg", 3 | "cgB": "/home/silasm/work/github/MetaCG/build2/../tools/cgdiff/test/integration/input/cgB_global_md.mcg", 4 | "ignoring": [], 5 | "diff": { 6 | "nodeDiffs": {}, 7 | "globalMetaDiff": { 8 | "entryFunction": { 9 | "aValue": "\"thisIsMain\"", 10 | "bValue": "\"thisIsNotMain\"" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTUAA/0067.cpp: -------------------------------------------------------------------------------- 1 | // Test for the alias analysis to check that it can generate unique USRs when macros are involved 2 | int foo(int a) { return 5 + a; } 3 | 4 | #define TWICE(a) \ 5 | foo(a); \ 6 | foo(a + 1); 7 | 8 | #define MY_MAX(a, b) (((a) < (b)) ? (b) : (a)) 9 | 10 | int main() { 11 | TWICE(5); 12 | return MY_MAX(8, foo(2)); 13 | } 14 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0207.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | func_t f0(func_t f) { return f; } 5 | func_t f1(func_t f) { return f0(f); } 6 | func_t f2(func_t f) { return f1(f); } 7 | func_t f3(func_t f) { return f2(f); } 8 | func_t f4(func_t f) { return f3(f); } 9 | func_t f5(func_t f) { return f4(f); } 10 | func_t f6(func_t f) { return f5(f); } 11 | func_t f7(func_t f) { return f6(f); } 12 | func_t f8(func_t f) { return f7(f); } 13 | func_t f9(func_t f) { return f8(f); } 14 | 15 | void foo() {} 16 | 17 | int main() { 18 | auto f = f9(foo); 19 | f(); 20 | } 21 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0021.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of middle class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | class MyClassDeriveDerive : public MyClassDerive { 14 | public: 15 | void foo() override {}; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClassDerive* mc; 22 | MyClassDeriveDerive mcd; 23 | mc = &mcd; 24 | mc->foo(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0209.cpp: -------------------------------------------------------------------------------- 1 | // we currently do not do return poitner tracing 2 | // depending on how common this is (and how much of a difference it makes from the all alias assumption) 3 | // we could probably implement this? 4 | struct A { 5 | void foo() {} 6 | void bar() {} 7 | void baz() {} 8 | }; 9 | using func_t = void (A::*)(); 10 | func_t get_f(bool b) { 11 | func_t fooPtr; 12 | fooPtr = &A::foo; 13 | if (b) { 14 | return &A::bar; 15 | } 16 | return fooPtr; 17 | } 18 | int main() { 19 | A a; 20 | auto f = get_f(1); 21 | (a.*f)(); 22 | } 23 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/singleTU/0006.cpp_disabled: -------------------------------------------------------------------------------- 1 | /** 2 | * File: CalledDeclTest.cpp 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | //This test is currently disabled as the header files from vector and iostream differ from system to system 8 | 9 | #include 10 | #include 11 | 12 | int main(int argc, char** argv) { 13 | std::vector v; 14 | v.push_back(argc); 15 | 16 | std::cout << "Hello world!" << std::endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/03_member_ptr.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | struct A { 6 | void foo() { std::cout << "A::foo()" << std::endl; } 7 | }; 8 | 9 | extern "C" void call_member(void (A::*ptr)(), A* obj) { 10 | // CHECK: Traversing function: call_member 11 | A a; 12 | // CHECK-NOT: Virtual call identified 13 | // CHECK: Call is other indirect call 14 | (obj->*ptr)(); 15 | } 16 | 17 | int main() { 18 | A a; 19 | call_member(&A::foo, &a); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/04_ptr_to_vfun.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | struct A { 6 | virtual void foo() { std::cout << "A::foo()" << std::endl; } 7 | }; 8 | 9 | extern "C" void call_virtual(void (A::*ptr)(), A* obj) { 10 | // CHECK: Traversing function: call_virtual 11 | // CHECK-NOT: Virtual call identified 12 | // CHECK: Call is other indirect call 13 | (obj->*ptr)(); 14 | } 15 | 16 | int main() { 17 | A a; 18 | call_virtual(&A::foo, &a); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/functionPointers/0207.cpp: -------------------------------------------------------------------------------- 1 | 2 | using func_t = void (*)(); 3 | 4 | func_t f0(func_t f) { return f; } 5 | func_t f1(func_t f) { return f0(f); } 6 | func_t f2(func_t f) { return f1(f); } 7 | func_t f3(func_t f) { return f2(f); } 8 | func_t f4(func_t f) { return f3(f); } 9 | func_t f5(func_t f) { return f4(f); } 10 | func_t f6(func_t f) { return f5(f); } 11 | func_t f7(func_t f) { return f6(f); } 12 | func_t f8(func_t f) { return f7(f); } 13 | func_t f9(func_t f) { return f8(f); } 14 | 15 | void foo() {} 16 | 17 | int main() { 18 | auto f = f9(foo); 19 | f(); 20 | } 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0021.cpp: -------------------------------------------------------------------------------- 1 | // call to overwritten function by pointer of middle class 2 | 3 | class MyClass { 4 | public: 5 | virtual void foo() {} 6 | }; 7 | 8 | class MyClassDerive : public MyClass { 9 | public: 10 | void foo() override; 11 | }; 12 | 13 | class MyClassDeriveDerive : public MyClassDerive { 14 | public: 15 | void foo() override {}; 16 | }; 17 | 18 | void MyClassDerive::foo() {} 19 | 20 | int main(int argc, char* argv[]) { 21 | MyClassDerive* mc; 22 | MyClassDeriveDerive mcd; 23 | mc = &mcd; 24 | mc->foo(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /cgcollector/test/input/virtualCalls/0017.cpp: -------------------------------------------------------------------------------- 1 | // override multiple functions 2 | // override function of super super class 3 | 4 | class MyClass { 5 | public: 6 | virtual void foo() {} 7 | }; 8 | 9 | class MyClass2 { 10 | public: 11 | virtual void foo() {} 12 | }; 13 | 14 | class MyClassStep : public MyClass2 {}; 15 | 16 | class MyClassDerive : public MyClass, public MyClassStep { 17 | public: 18 | void foo() override; 19 | }; 20 | 21 | void MyClassDerive::foo() {} 22 | 23 | int main(int argc, char* argv[]) { 24 | MyClass mc; 25 | MyClassDerive mcd; 26 | mc.foo(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /cgcollector/test/integration/cgvalidate/input/virtual/exp4.cpp: -------------------------------------------------------------------------------- 1 | struct Object { 2 | public: 3 | virtual void doSomething() {} 4 | Object() {} 5 | virtual ~Object() = default; 6 | }; 7 | 8 | struct Derived : public Object { 9 | public: 10 | void doSomething() override {} 11 | Derived() {} 12 | virtual ~Derived() {} 13 | }; 14 | 15 | struct Derived2 : public Derived { 16 | void doSomething() override {} 17 | Derived2() {} 18 | virtual ~Derived2() {} 19 | }; 20 | 21 | int main() { 22 | Object* obj = new Derived2(); 23 | obj->doSomething(); 24 | 25 | delete obj; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tools/cgpatch/test/pass-tests/vcall-detection-test/05_ref_call.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %cgpatchcxx --verbose clang++ %s %cppargs -emit-llvm -S | %filecheck %s 2 | 3 | #include 4 | 5 | struct A { 6 | virtual void foo() { std::cout << "A::foo()" << std::endl; } 7 | }; 8 | 9 | struct B : public A { 10 | void foo() override { std::cout << "B::foo()" << std::endl; } 11 | }; 12 | 13 | extern "C" void call_virtual(A& a) { 14 | // CHECK: Traversing function: call_virtual 15 | // CHECK: Virtual call identified 16 | a.foo(); 17 | } 18 | 19 | int main() { 20 | B b; 21 | call_virtual(b); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0004.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_Z3foov": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 4, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "main": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 1, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /graph/include/CgTypes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File: CgTypes.h 3 | * License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | #ifndef METACG_GRAPH_CGNODEPTR_H 7 | #define METACG_GRAPH_CGNODEPTR_H 8 | 9 | #include 10 | #include 11 | 12 | namespace metacg { 13 | class CgNode; 14 | class Callgraph; 15 | 16 | using NodeId = size_t; 17 | 18 | using CgNodePtr = std::unique_ptr; 19 | using CgNodeRawPtrUSet = std::unordered_set; 20 | 21 | } // namespace metacg 22 | 23 | #endif -------------------------------------------------------------------------------- /pgis/test/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Now simply link against gtest or gtest_main as needed. Eg 2 | add_executable( 3 | pgistests 4 | CallgraphTest.cpp 5 | # CallgraphManagerTest.cpp 6 | IPCGEstimatorPhaseTest.cpp 7 | LegacyMCGReaderTest.cpp 8 | loadImbalance/LIConfigTest.cpp 9 | loadImbalance/LIEstimatorPhaseTest.cpp 10 | loadImbalance/LIMetricTest.cpp 11 | PIRAPGISMetadataTest.cpp 12 | ) 13 | 14 | add_googletest_libraries(pgistests) 15 | add_pgis(pgistests) 16 | add_metacg(pgistests) 17 | 18 | # add_library(ipcg) target_link_libraries(pgistests) 19 | 20 | add_test(NAME pgis_unittests COMMAND pgistests) 21 | -------------------------------------------------------------------------------- /tools/cgcollector2/test/input/virtualCalls/0017.cpp: -------------------------------------------------------------------------------- 1 | // override multiple functions 2 | // override function of super super class 3 | 4 | class MyClass { 5 | public: 6 | virtual void foo() {} 7 | }; 8 | 9 | class MyClass2 { 10 | public: 11 | virtual void foo() {} 12 | }; 13 | 14 | class MyClassStep : public MyClass2 {}; 15 | 16 | class MyClassDerive : public MyClass, public MyClassStep { 17 | public: 18 | void foo() override; 19 | }; 20 | 21 | void MyClassDerive::foo() {} 22 | 23 | int main(int argc, char* argv[]) { 24 | MyClass mc; 25 | MyClassDerive mcd; 26 | mc.foo(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /cgcollector/test/input/multiTU/0043_a.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_Z3barv": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "_Z3foov": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 1, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0226.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_Z3boo1A": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "_Z3fooPii": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 1, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/singleTU/0227.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_Z3baaPfi": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 3, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "_Z3foofi": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 1, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/functionPointers/0100.gtipcg: -------------------------------------------------------------------------------- 1 | { 2 | "_Z3foof": { 3 | "callees": [], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 1, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "main": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 3, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cgcollector/test/input/metaCollectors/numStatements/0033.cpp: -------------------------------------------------------------------------------- 1 | 2 | int sentinel(int f) { return f / 2; } 3 | 4 | int bar(int f) { 5 | int k = f % 3; 6 | int n = 0; 7 | while (k > 0) { 8 | --k; 9 | ++n; 10 | } 11 | return sentinel(n); 12 | } 13 | 14 | int foo(int k) { 15 | ++k; 16 | return sentinel(4 * k); 17 | } 18 | 19 | int main(int argc, char** argv) { 20 | int k = 12; 21 | int i = foo(k); 22 | 23 | while (i < k) { 24 | if (k % 2 == 0) { 25 | ++k; 26 | } else { 27 | ++i; 28 | ++k; 29 | } 30 | ++i; 31 | } 32 | 33 | int n = bar(i); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /container/devel: -------------------------------------------------------------------------------- 1 | FROM metacg:base 2 | 3 | WORKDIR /opt/metacg 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | 7 | RUN apt-get update && apt-get install -y ssh rsync tar 8 | 9 | RUN ( \ 10 | echo 'LogLevel DEBUG2'; \ 11 | echo 'PermitRootLogin yes'; \ 12 | echo 'PasswordAuthentication yes'; \ 13 | echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \ 14 | ) > /etc/ssh/sshd_config_test_clion \ 15 | && mkdir /run/sshd 16 | 17 | RUN useradd -m user \ 18 | && yes password | passwd user 19 | 20 | RUN usermod -s /bin/bash user 21 | 22 | CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config_test_clion"] 23 | -------------------------------------------------------------------------------- /graph/src/MCGBaseInfo.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File: MCGBaseInfo.cpp 3 | * License: Part of the metacg project. Licensed under BSD 3 clause license. See LICENSE.txt file at 4 | * https://github.com/tudasc/metacg/LICENSE.txt 5 | */ 6 | 7 | #include "MCGBaseInfo.h" 8 | #include "config.h" 9 | namespace metacg { 10 | 11 | // This must be in its own file as to not expose config.h header to linking programs 12 | MCGGeneratorVersionInfo getCGCollectorGeneratorInfo() { 13 | const std::string cgcCollName("CGCollector"); 14 | return {cgcCollName, MetaCG_VERSION_MAJOR, MetaCG_VERSION_MINOR, MetaCG_GIT_SHA}; 15 | } 16 | } // namespace metacg 17 | -------------------------------------------------------------------------------- /pgis/test/integration/inputstatic/003.ipcg: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "callees": ["foo"], 4 | "doesOverride": false, 5 | "hasBody": true, 6 | "isVirtual": false, 7 | "numStatements": 2, 8 | "overriddenBy": [], 9 | "overriddenFunctions": [], 10 | "parents": [] 11 | }, 12 | "foo": { 13 | "callees": [], 14 | "doesOverride": false, 15 | "hasBody": true, 16 | "isVirtual": false, 17 | "numStatements": 50000, 18 | "overriddenBy": [], 19 | "overriddenFunctions": [], 20 | "parents": ["main"] 21 | } 22 | } 23 | --------------------------------------------------------------------------------