CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
73 lines
2.9 KiB
C++
73 lines
2.9 KiB
C++
//===- unittest/StaticAnalyzer/AnalyzerOptionsTest.cpp - SA Options test --===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
|
|
#include "clang/StaticAnalyzer/Core/Checker.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace clang {
|
|
namespace ento {
|
|
|
|
TEST(StaticAnalyzerOptions, getRegisteredCheckers) {
|
|
auto IsDebugChecker = [](StringRef CheckerName) {
|
|
return CheckerName.starts_with("debug");
|
|
};
|
|
auto IsAlphaChecker = [](StringRef CheckerName) {
|
|
return CheckerName.starts_with("alpha");
|
|
};
|
|
const auto &AllCheckers =
|
|
AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
|
|
EXPECT_FALSE(llvm::any_of(AllCheckers, IsDebugChecker));
|
|
EXPECT_TRUE(llvm::any_of(AllCheckers, IsAlphaChecker));
|
|
|
|
const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers();
|
|
EXPECT_FALSE(llvm::any_of(StableCheckers, IsDebugChecker));
|
|
EXPECT_FALSE(llvm::any_of(StableCheckers, IsAlphaChecker));
|
|
}
|
|
|
|
TEST(StaticAnalyzerOptions, SearchInParentPackageTests) {
|
|
AnalyzerOptions Opts;
|
|
Opts.Config["Outer.Inner.CheckerOne:Option"] = "true";
|
|
Opts.Config["Outer.Inner:Option"] = "false";
|
|
Opts.Config["Outer.Inner:Option2"] = "true";
|
|
Opts.Config["Outer:Option2"] = "false";
|
|
|
|
StringRef CheckerOneName = "Outer.Inner.CheckerOne";
|
|
StringRef CheckerTwoName = "Outer.Inner.CheckerTwo";
|
|
|
|
// CheckerTwo one has Option specified as true. It should read true regardless
|
|
// of search mode.
|
|
EXPECT_TRUE(Opts.getCheckerBooleanOption(CheckerOneName, "Option"));
|
|
// The package option is overridden with a checker option.
|
|
EXPECT_TRUE(Opts.getCheckerBooleanOption(CheckerOneName, "Option", true));
|
|
// The Outer package option is overridden by the Inner package option. No
|
|
// package option is specified.
|
|
EXPECT_TRUE(Opts.getCheckerBooleanOption(CheckerOneName, "Option2", true));
|
|
// No package option is specified and search in packages is turned off. We
|
|
// should assert here, but we can't test that.
|
|
//Opts.getCheckerBooleanOption(&CheckerOne, "Option2");
|
|
//Opts.getCheckerBooleanOption(&CheckerOne, "Option2");
|
|
|
|
// Checker true has no option specified. It should get false when search in
|
|
// parents turned on.
|
|
EXPECT_FALSE(Opts.getCheckerBooleanOption(CheckerTwoName, "Option", true));
|
|
// In any other case, we should assert, that we cannot test unfortunately.
|
|
//Opts.getCheckerBooleanOption(&CheckerTwo, "Option");
|
|
//Opts.getCheckerBooleanOption(&CheckerTwo, "Option");
|
|
}
|
|
|
|
TEST(StaticAnalyzerOptions, StringOptions) {
|
|
AnalyzerOptions Opts;
|
|
Opts.Config["Outer.Inner.CheckerOne:Option"] = "StringValue";
|
|
EXPECT_TRUE("StringValue" == Opts.getCheckerStringOption(
|
|
"Outer.Inner.CheckerOne", "Option"));
|
|
}
|
|
|
|
} // end namespace ento
|
|
} // end namespace clang
|