Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
23e288e
Add utility function to aid src-code based unittests
fabianbs96 Jun 23, 2025
b895cee
half of xtaint test, stuck on 12
mxHuber Jun 28, 2025
d602cf4
Fixed all but 09 and 12
mxHuber Jun 29, 2025
9c092e9
fixed all enabled ext taint tests
mxHuber Jun 30, 2025
e12334e
reworked test structure
mxHuber Jul 2, 2025
2ea2e4f
refractor + more tests. Weird errors
mxHuber Jul 8, 2025
d1bd97f
debug commit
mxHuber Jul 15, 2025
3e57880
Fix psr::getDILocation()
fabianbs96 Jul 15, 2025
d878a9c
std::variant for SrcCodeLocationEntry
mxHuber Jul 15, 2025
b976e87
bug fixed + ext taint test works
mxHuber Jul 16, 2025
ed2708a
compile tests as dbg + ground truths
mxHuber Jul 20, 2025
2cb26c1
Fix Gt for UninitTest_02_SHOULD_LEAK
fabianbs96 Jul 21, 2025
379444f
Add TestingSrcLocation
fabianbs96 Jul 21, 2025
73df79f
GLCA nearly done, questions for meeting
mxHuber Jul 22, 2025
762ea01
Merge remote-tracking branch 'refs/remotes/origin/f-SrcBasedUnittests…
mxHuber Jul 22, 2025
17bb913
taint double free tests fail
mxHuber Jul 24, 2025
99b582b
Fixed IFDSConstAnalysisTest
mxHuber Jul 25, 2025
5c6d82c
fixed tainttest and segfaults + refactoring
mxHuber Jul 25, 2025
a660468
Fix AnalysisPrinterTest
fabianbs96 Aug 4, 2025
66fbc02
Convert AnalysisPrinterTest to src-code-based ground-truth
fabianbs96 Aug 4, 2025
37d65f9
Start converting InstInterationAnalysis tests
fabianbs96 Aug 4, 2025
6aa8ab9
Convert some more IIA test cases
fabianbs96 Aug 5, 2025
792c0f7
Add more IIA tests
fabianbs96 Aug 6, 2025
0e8d8f6
Convert FIIA-test + fix use-after-free in IIA test
fabianbs96 Aug 8, 2025
14c119a
HandleTypeState_03 not working
mxHuber Aug 11, 2025
785b446
All but three fileio tests work
mxHuber Aug 15, 2025
cbb542a
UninitVarTest fixed all but one
mxHuber Aug 18, 2025
eda2637
fixed all but 03 of TSAnalysisFile
mxHuber Aug 20, 2025
52ff60c
Fixed all but one test
mxHuber Aug 21, 2025
2adb32c
Fixed UninitTest_21
mxHuber Aug 21, 2025
5d2bfee
Enable modeling of instruction-operands in TestingSrcLocation + fix 2…
fabianbs96 Aug 22, 2025
a3bd34e
reworked test 06
mxHuber Aug 22, 2025
254f8b6
cleanup
mxHuber Aug 22, 2025
301b8ab
readded LIBCPP_GTEST_SKIP
mxHuber Aug 22, 2025
87a1ded
fixed use after scope in taint analysis test
mxHuber Aug 25, 2025
f951eb7
Merge branch 'development' into f-SrcBasedUnittests
fabianbs96 Aug 25, 2025
e71d933
Make IDEExtendedTaintAnalysisTest more compact
fabianbs96 Aug 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CheckOptions:
- key: readability-identifier-naming.ParameterIgnoredRegexp
value: (d|d1|d2|d3|d4|d5|eP|f|n)
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: (try_emplace|from_json|to_json|equal_to|to_string|DToString|NToString|FToString|LToString|hash_value)
value: (try_emplace|from_json|to_json|equal_to|to_string|DToString|NToString|FToString|LToString|hash_value|dyn_cast)
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 1
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand Down
8 changes: 4 additions & 4 deletions include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ class IDESolver
} else {
// Get the fact-ID
D1FactId = G.getFactID(D1Fact);
std::string D1Label = DToString(D1Fact);
std::string D1Label{DToString(D1Fact)};

// Get or create the fact subgraph
D1FSG = FG->getOrCreateFactSG(D1FactId, D1Label);
Expand All @@ -1634,7 +1634,7 @@ class IDESolver
if (!IDEProblem.isZeroValue(D2Fact)) {
// Get the fact-ID
D2FactId = G.getFactID(D2Fact);
std::string D2Label = DToString(D2Fact);
std::string D2Label{DToString(D2Fact)};
DOTNode D2 = {FuncName, D2Label, N2StmtId, D2FactId, false, true};
std::string EFLabel;
auto EFVec = IntermediateEdgeFunctions[std::make_tuple(
Expand Down Expand Up @@ -1719,7 +1719,7 @@ class IDESolver
} else {
// Get the fact-ID
D1FactId = G.getFactID(D1Fact);
std::string D1Label = DToString(D1Fact);
std::string D1Label{DToString(D1Fact)};
D1 = {FNameOfN1, D1Label, N1StmtId, D1FactId, false, true};
// FG should already exist even for single statement functions
if (!G.containsFactSG(FNameOfN1, D1FactId)) {
Expand All @@ -1738,7 +1738,7 @@ class IDESolver
} else {
// Get the fact-ID
D2FactId = G.getFactID(D2Fact);
std::string D2Label = DToString(D2Fact);
std::string D2Label{DToString(D2Fact)};
D2 = {FNameOfN2, D2Label, N2StmtId, D2FactId, false, true};
// FG should already exist even for single statement functions
if (!G.containsFactSG(FNameOfN2, D2FactId)) {
Expand Down
11 changes: 7 additions & 4 deletions include/phasar/Domain/LatticeDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define PHASAR_DOMAIN_LATTICEDOMAIN_H

#include "phasar/Utils/ByRef.h"
#include "phasar/Utils/DebugOutput.h"
#include "phasar/Utils/JoinLattice.h"
#include "phasar/Utils/TypeTraits.h"

Expand Down Expand Up @@ -100,9 +101,7 @@ struct LatticeDomain : public std::variant<Top, L, Bottom> {
}
};

template <typename L,
typename = std::void_t<decltype(std::declval<llvm::raw_ostream &>()
<< std::declval<L>())>>
template <typename L>
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const LatticeDomain<L> &LD) {
if (LD.isBottom()) {
Expand All @@ -114,7 +113,11 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,

const auto *Val = LD.getValueOrNull();
assert(Val && "Only alternative remaining is L");
return OS << *Val;
if constexpr (is_llvm_printable_v<L>) {
return OS << *Val;
} else {
return OS << PrettyPrinter{*Val};
}
}

template <typename L>
Expand Down
11 changes: 8 additions & 3 deletions include/phasar/Utils/BitVectorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ class BitVectorSet {

[[nodiscard]] size_t size() const noexcept { return Bits.count(); }

[[nodiscard]] const BitVectorTy &getBits() const &noexcept { return Bits; }
[[nodiscard]] BitVectorTy &getBits() &noexcept { return Bits; }
[[nodiscard]] BitVectorTy &&getBits() &&noexcept { return std::move(Bits); }
[[nodiscard]] const BitVectorTy &getBits() const & noexcept { return Bits; }
[[nodiscard]] BitVectorTy &getBits() & noexcept { return Bits; }
[[nodiscard]] BitVectorTy &&getBits() && noexcept { return std::move(Bits); }

friend bool operator==(const BitVectorSet &Lhs, const BitVectorSet &Rhs) {
bool LeftEmpty = Lhs.empty();
Expand Down Expand Up @@ -392,6 +392,11 @@ class BitVectorSet {
EndIter.setBits(Bits);
return EndIter;
}

static void clearPosition() {
Position.left.clear();
Position.right.clear();
}
};

// Overloads with the other intersectWith functions from Utilities.h
Expand Down
12 changes: 8 additions & 4 deletions lib/PhasarLLVM/Utils/LLVMIRToSrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,19 @@ static llvm::DISubprogram *getDISubprogram(const llvm::Value *V) {

llvm::DILocation *psr::getDILocation(const llvm::Value *V) {
// Arguments and Instruction such as AllocaInst
if (auto *DbgIntr = getDbgVarIntrinsic(V)) {
if (auto *MN = DbgIntr->getMetadata(llvm::LLVMContext::MD_dbg)) {

if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
if (auto *MN = I->getMetadata(llvm::LLVMContext::MD_dbg)) {
return llvm::dyn_cast<llvm::DILocation>(MN);
}
} else if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
if (auto *MN = I->getMetadata(llvm::LLVMContext::MD_dbg)) {
}

if (auto *DbgIntr = getDbgVarIntrinsic(V)) {
if (auto *MN = DbgIntr->getMetadata(llvm::LLVMContext::MD_dbg)) {
return llvm::dyn_cast<llvm::DILocation>(MN);
}
}

return nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ set(Sources
)

foreach(TEST_SRC ${Sources})
generate_ll_file(FILE ${TEST_SRC})
generate_ll_file(FILE ${TEST_SRC} DEBUG)
endforeach(TEST_SRC)
5 changes: 4 additions & 1 deletion test/llvm_test_code/general_linear_constant/NullTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ char *foo(char *str) { return str; }

extern void puts(const char *);

int main() { puts(foo(0)); }
int main() {
puts(foo(0));
return 0;
}
2 changes: 2 additions & 0 deletions test/llvm_test_code/inst_interaction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ set(SourcesOpt

foreach(TEST_SRC ${Sources})
generate_ll_file(FILE ${TEST_SRC})
generate_ll_file(FILE ${TEST_SRC} DEBUG)
endforeach(TEST_SRC)

foreach(TEST_SRC ${SourcesOpt})
generate_ll_file(FILE ${TEST_SRC} O1)
generate_ll_file(FILE ${TEST_SRC} DEBUG O1)
endforeach(TEST_SRC)
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ file(GLOB openssl_files *.c *.cpp)

foreach(TEST_SRC ${openssl_files})
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME)
generate_ll_file(FILE ${TEST_SRC_FILE})
generate_ll_file(FILE ${TEST_SRC_FILE} DEBUG)
endforeach(TEST_SRC)
2 changes: 1 addition & 1 deletion test/llvm_test_code/openssl/secure_heap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ file(GLOB openssl_files *.c *.cpp)

foreach(TEST_SRC ${openssl_files})
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME)
generate_ll_file(FILE ${TEST_SRC_FILE})
generate_ll_file(FILE ${TEST_SRC_FILE} DEBUG)
endforeach(TEST_SRC)
2 changes: 1 addition & 1 deletion test/llvm_test_code/openssl/secure_memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ file(GLOB openssl_files *.c *.cpp)

foreach(TEST_SRC ${openssl_files})
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME)
generate_ll_file(FILE ${TEST_SRC_FILE})
generate_ll_file(FILE ${TEST_SRC_FILE} DEBUG)
endforeach(TEST_SRC)
2 changes: 1 addition & 1 deletion test/llvm_test_code/taint_analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(NoMem2regSources
)

foreach(TEST_SRC ${NoMem2regSources})
generate_ll_file(FILE ${TEST_SRC})
generate_ll_file(FILE ${TEST_SRC} DEBUG)
endforeach(TEST_SRC)

add_subdirectory(dummy_source_sink)
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
file(GLOB typestate_files *.c *.cpp)

foreach(TEST_SRC ${typestate_files})
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME)
generate_ll_file(FILE ${TEST_SRC_FILE})
endforeach(TEST_SRC)

foreach(TEST_SRC ${typestate_files})
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME)
generate_ll_file(FILE ${TEST_SRC_FILE} DEBUG)
Expand Down
11 changes: 2 additions & 9 deletions test/llvm_test_code/xtaint/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(XTAINT_SOURCES
set(XTAINT_DBG_SOURCES
xtaint01.cpp
xtaint01_json.cpp
# xtaint01_json.cpp
xtaint02.cpp
xtaint03.cpp
Expand All @@ -24,14 +25,6 @@ set(XTAINT_SOURCES
xtaint21.cpp
)

set(XTAINT_DBG_SOURCES
xtaint01_json.cpp
)

foreach(TEST_SRC ${XTAINT_SOURCES})
generate_ll_file(FILE ${TEST_SRC})
endforeach(TEST_SRC)

foreach(TEST_SRC ${XTAINT_DBG_SOURCES})
generate_ll_file(FILE ${TEST_SRC} DEBUG)
endforeach(TEST_SRC)
Loading
Loading