@@ -29,8 +29,8 @@ class TaintConfigTest : public ::testing::Test {
2929 void SetUp () override { psr::ValueAnnotationPass::resetValueID (); }
3030
3131 std::string getFunctionName (std::string MangledFunctionName) {
32- if (MangledFunctionName.find (" ( " ) != std::string::npos) {
33- return MangledFunctionName.substr (0 , MangledFunctionName.find (" ( " ));
32+ if (MangledFunctionName.find (' ( ' ) != std::string::npos) {
33+ return MangledFunctionName.substr (0 , MangledFunctionName.find (' ( ' ));
3434 }
3535 return MangledFunctionName;
3636 }
@@ -83,7 +83,7 @@ TEST_F(TaintConfigTest, Basic_02) {
8383 std::cout << Config << ' \n ' ;
8484 const llvm::Value *I1 = IR.getInstruction (9 );
8585 const llvm::Value *I2 = IR.getInstruction (23 );
86- ASSERT_TRUE (Config.isSource (I2 ));
86+ ASSERT_TRUE (Config.isSource (I1 ));
8787 ASSERT_TRUE (Config.isSource (I2));
8888}
8989
@@ -92,9 +92,9 @@ TEST_F(TaintConfigTest, Basic_03) {
9292 psr::ProjectIRDB IR ({PathToAttrTaintConfigTestCode + File});
9393 psr::TaintConfig Config (IR);
9494 std::cout << Config << ' \n ' ;
95- const auto *taintPair = IR.getFunction (" taintPair" );
96- assert (taintPair );
97- for (const auto &User : taintPair ->users ()) {
95+ const auto *TaintPair = IR.getFunction (" taintPair" );
96+ assert (TaintPair );
97+ for (const auto &User : TaintPair ->users ()) {
9898 if (llvm::isa<llvm::CallBase>(User)) {
9999 ASSERT_TRUE (Config.isSource (User));
100100 }
@@ -208,7 +208,7 @@ TEST_F(TaintConfigTest, StaticFun_02) {
208208 std::cout << Config << ' \n ' ;
209209 const llvm::Value *CallInst = IR.getInstruction (16 );
210210 const auto *I = llvm::dyn_cast<llvm::CallBase>(CallInst);
211- ASSERT_TRUE (Config.isSource (I->getCalledFunction ()->getArg (0 )));
211+ ASSERT_TRUE (I && Config.isSource (I->getCalledFunction ()->getArg (0 )));
212212 for (const auto *F : IR.getAllFunctions ()) {
213213 std::string FName = getFunctionName (llvm::demangle (F->getName ().str ()));
214214 if (FName == " bar" ) {
@@ -288,7 +288,7 @@ TEST_F(TaintConfigTest, Basic_02_Json) {
288288 std::cout << TConfig << ' \n ' ;
289289 const llvm::Value *I1 = IR.getInstruction (7 );
290290 const llvm::Value *I2 = IR.getInstruction (18 );
291- ASSERT_TRUE (TConfig.isSource (I2 ));
291+ ASSERT_TRUE (TConfig.isSource (I1 ));
292292 ASSERT_TRUE (TConfig.isSource (I2));
293293}
294294
@@ -300,9 +300,9 @@ TEST_F(TaintConfigTest, Basic_03_Json) {
300300 psr::ProjectIRDB IR ({PathToJsonTaintConfigTestCode + File});
301301 psr::TaintConfig TConfig (IR, JsonConfig);
302302 std::cout << TConfig << ' \n ' ;
303- const auto *taintPair = IR.getFunction (" taintPair" );
304- assert (taintPair );
305- for (const auto &User : taintPair ->users ()) {
303+ const auto *TaintPair = IR.getFunction (" taintPair" );
304+ assert (TaintPair );
305+ for (const auto &User : TaintPair ->users ()) {
306306 if (llvm::isa<llvm::CallBase>(User)) {
307307 ASSERT_TRUE (TConfig.isSource (User));
308308 }
@@ -378,8 +378,8 @@ TEST_F(TaintConfigTest, FunMember_02_Json) {
378378 ASSERT_TRUE (TConfig.isSource (I4));
379379 const auto *DestructorX = IR.getFunction (" _ZN1XD2Ev" );
380380 assert (DestructorX);
381- for (auto Arg = DestructorX->arg_begin (); Arg != DestructorX-> arg_end ();
382- ++Arg) {
381+ for (const auto * Arg = DestructorX->arg_begin ();
382+ Arg != DestructorX-> arg_end (); ++Arg) {
383383 ASSERT_TRUE (TConfig.isSink (Arg));
384384 }
385385
@@ -445,7 +445,7 @@ TEST_F(TaintConfigTest, StaticFun_02_Json) {
445445 std::cout << TConfig << ' \n ' ;
446446 const llvm::Value *CallInst = IR.getInstruction (13 );
447447 const auto *I = llvm::dyn_cast<llvm::CallBase>(CallInst);
448- ASSERT_TRUE (TConfig.isSource (I->getCalledFunction ()->getArg (0 )));
448+ ASSERT_TRUE (I && TConfig.isSource (I->getCalledFunction ()->getArg (0 )));
449449 for (const auto *F : IR.getAllFunctions ()) {
450450 std::string FName = getFunctionName (llvm::demangle (F->getName ().str ()));
451451 if (FName == " bar" ) {
0 commit comments