From 748c139adebf58b144bf4ecc2a2333d9ad66ecdc Mon Sep 17 00:00:00 2001 From: Kristof Umann Date: Fri, 8 Mar 2019 16:00:42 +0000 Subject: [analyzer] Emit an error rather than assert on invalid checker option input Asserting on invalid input isn't very nice, hence the patch to emit an error instead. This is the first of many patches to overhaul the way we handle checker options. Differential Revision: https://reviews.llvm.org/D57850 llvm-svn: 355704 --- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp') diff --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp index df5b46ebd2e..abc90986f40 100644 --- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Driver/DriverDiagnostic.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" @@ -348,8 +349,9 @@ void ento::registerPaddingChecker(CheckerManager &Mgr) { auto *Checker = Mgr.registerChecker(); Checker->AllowedPad = Mgr.getAnalyzerOptions() .getCheckerIntegerOption(Checker, "AllowedPad", 24); - assert(Checker->AllowedPad >= 0 && - "AllowedPad option should be non-negative"); + if (Checker->AllowedPad < 0) + Mgr.reportInvalidCheckerOptionValue( + Checker, "AllowedPad", "a non-negative value"); } bool ento::shouldRegisterPaddingChecker(const LangOptions &LO) { -- cgit v1.2.3