summaryrefslogtreecommitdiffstats
path: root/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
diff options
context:
space:
mode:
authorKristof Umann <dkszelethus@gmail.com>2019-03-04 00:28:16 +0000
committerKristof Umann <dkszelethus@gmail.com>2019-03-04 00:28:16 +0000
commit088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d (patch)
tree3ff1101103765384e7f37bb997ee6cd88faf4fe1 /clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
parent195a62e9ae50594e469398631a24f4bc26061c56 (diff)
downloadbcm5719-llvm-088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d.tar.gz
bcm5719-llvm-088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d.zip
[analyzer] Enable subcheckers to possess checker options
Under the term "subchecker", I mean checkers that do not have a checker class on their own, like unix.MallocChecker to unix.DynamicMemoryModeling. Since a checker object was required in order to retrieve checker options, subcheckers couldn't possess options on their own. This patch is also an excuse to change the argument order of getChecker*Option, it always bothered me, now it resembles the actual command line argument (checkername:option=value). Differential Revision: https://reviews.llvm.org/D57579 llvm-svn: 355297
Diffstat (limited to 'clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp')
-rw-r--r--clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp b/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
index ff2c12ac1f1..0fb0c04b97a 100644
--- a/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ b/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -48,28 +48,28 @@ TEST(StaticAnalyzerOptions, SearchInParentPackageTests) {
}
};
- // Checker one has Option specified as true. It should read true regardless of
- // search mode.
+ // CheckerTwo one has Option specified as true. It should read true regardless
+ // of search mode.
CheckerOneMock CheckerOne;
- EXPECT_TRUE(Opts.getCheckerBooleanOption("Option", false, &CheckerOne));
+ EXPECT_TRUE(Opts.getCheckerBooleanOption(&CheckerOne, "Option", false));
// The package option is overridden with a checker option.
- EXPECT_TRUE(Opts.getCheckerBooleanOption("Option", false, &CheckerOne,
+ EXPECT_TRUE(Opts.getCheckerBooleanOption(&CheckerOne, "Option", false,
true));
// The Outer package option is overridden by the Inner package option. No
// package option is specified.
- EXPECT_TRUE(Opts.getCheckerBooleanOption("Option2", false, &CheckerOne,
+ EXPECT_TRUE(Opts.getCheckerBooleanOption(&CheckerOne, "Option2", false,
true));
// No package option is specified and search in packages is turned off. The
// default value should be returned.
- EXPECT_FALSE(Opts.getCheckerBooleanOption("Option2", false, &CheckerOne));
- EXPECT_TRUE(Opts.getCheckerBooleanOption("Option2", true, &CheckerOne));
+ EXPECT_FALSE(Opts.getCheckerBooleanOption(&CheckerOne, "Option2", false));
+ EXPECT_TRUE(Opts.getCheckerBooleanOption(&CheckerOne, "Option2", true));
// Checker true has no option specified. It should get the default value when
// search in parents turned off and false when search in parents turned on.
CheckerTwoMock CheckerTwo;
- EXPECT_FALSE(Opts.getCheckerBooleanOption("Option", false, &CheckerTwo));
- EXPECT_TRUE(Opts.getCheckerBooleanOption("Option", true, &CheckerTwo));
- EXPECT_FALSE(Opts.getCheckerBooleanOption("Option", true, &CheckerTwo, true));
+ EXPECT_FALSE(Opts.getCheckerBooleanOption(&CheckerTwo, "Option", false));
+ EXPECT_TRUE(Opts.getCheckerBooleanOption(&CheckerTwo, "Option", true));
+ EXPECT_FALSE(Opts.getCheckerBooleanOption(&CheckerTwo, "Option", true, true));
}
TEST(StaticAnalyzerOptions, StringOptions) {
@@ -84,9 +84,17 @@ TEST(StaticAnalyzerOptions, StringOptions) {
CheckerOneMock CheckerOne;
EXPECT_TRUE("StringValue" ==
- Opts.getCheckerStringOption("Option", "DefaultValue", &CheckerOne));
+ Opts.getCheckerStringOption(&CheckerOne, "Option", "DefaultValue"));
EXPECT_TRUE("DefaultValue" ==
- Opts.getCheckerStringOption("Option2", "DefaultValue", &CheckerOne));
+ Opts.getCheckerStringOption(&CheckerOne, "Option2", "DefaultValue"));
}
+
+TEST(StaticAnalyzerOptions, SubCheckerOptions) {
+ AnalyzerOptions Opts;
+ Opts.Config["Outer.Inner.CheckerOne:Option"] = "StringValue";
+ EXPECT_TRUE("StringValue" == Opts.getCheckerStringOption(
+ "Outer.Inner.CheckerOne", "Option", "DefaultValue"));
+}
+
} // end namespace ento
} // end namespace clang
OpenPOWER on IntegriCloud