llvm-capstone/clang/test/Analysis/invalid-checker-option.c
Kristof Umann 83cc1b35d1 [analyzer] Remove the default value arg from getChecker*Option
Since D57922, the config table contains every checker option, and it's default
value, so having it as an argument for getChecker*Option is redundant.

By the time any of the getChecker*Option function is called, we verified the
value in CheckerRegistry (after D57860), so we can confidently assert here, as
any irregularities detected at this point must be a programmer error. However,
in compatibility mode, verification won't happen, so the default value must be
restored.

This implies something else, other than adding removing one more potential point
of failure -- debug.ConfigDumper will always contain valid values for
checker/package options!

Differential Revision: https://reviews.llvm.org/D59195

llvm-svn: 361042
2019-05-17 15:52:13 +00:00

98 lines
3.8 KiB
C

// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config RetainOneTwoThree:CheckOSObject=false \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-NON-EXISTENT-CHECKER
// Note that non-existent packages and checkers were always reported.
// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config RetainOneTwoThree:CheckOSObject=false \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-NON-EXISTENT-CHECKER
// CHECK-NON-EXISTENT-CHECKER: (frontend): no analyzer checkers or packages
// CHECK-NON-EXISTENT-CHECKER-SAME: are associated with 'RetainOneTwoThree'
// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=debug.ConfigDumper \
// RUN: -analyzer-checker=debug.AnalysisOrder \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config debug.AnalysisOrder:*=yesplease \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CORRECTED-BOOL-VALUE
// CHECK-CORRECTED-BOOL-VALUE: debug.AnalysisOrder:* = false
//
// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=debug.ConfigDumper \
// RUN: -analyzer-checker=optin.performance.Padding \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config optin.performance.Padding:AllowedPad=surpriseme \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CORRECTED-INT-VALUE
// CHECK-CORRECTED-INT-VALUE: optin.performance.Padding:AllowedPad = 24
// Every other error should be avoidable in compatiblity mode.
// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config debug.AnalysisOrder:Everything=false \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-NON-EXISTENT-CHECKER-OPTION
// CHECK-NON-EXISTENT-CHECKER-OPTION: (frontend): checker 'debug.AnalysisOrder'
// CHECK-NON-EXISTENT-CHECKER-OPTION-SAME: has no option called 'Everything'
// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config debug.AnalysisOrder:Everything=false
// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config debug.AnalysisOrder:*=nothankyou \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-BOOL-VALUE
// CHECK-INVALID-BOOL-VALUE: (frontend): invalid input for checker option
// CHECK-INVALID-BOOL-VALUE-SAME: 'debug.AnalysisOrder:*', that expects a
// CHECK-INVALID-BOOL-VALUE-SAME: boolean value
// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config debug.AnalysisOrder:*=nothankyou
// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config optin.performance.Padding:AllowedPad=surpriseme \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-INT-VALUE
// CHECK-INVALID-INT-VALUE: (frontend): invalid input for checker option
// CHECK-INVALID-INT-VALUE-SAME: 'optin.performance.Padding:AllowedPad', that
// CHECK-INVALID-INT-VALUE-SAME: expects an integer value
// RUN: %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config-compatibility-mode=true \
// RUN: -analyzer-config optin.performance.Padding:AllowedPad=surpriseme
// RUN: not %clang_analyze_cc1 -verify %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=sure \
// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-PACKAGE-VALUE
// CHECK-PACKAGE-VALUE: (frontend): invalid input for checker option
// CHECK-PACKAGE-VALUE-SAME: 'nullability:NoDiagnoseCallsToSystemHeaders', that
// CHECK-PACKAGE-VALUE-SAME: expects a boolean value
// expected-no-diagnostics
int main() {}