aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorBalazs Benics <balazs.benics@sigmatechnology.se>2022-06-14 09:42:58 +0200
committerBalazs Benics <balazs.benics@sigmatechnology.se>2022-06-14 09:42:58 +0200
commit24bd47dc172f5dc81de7baac880c55b1e615fa70 (patch)
tree5b301d8da0885284093f36b9b126a32f9a61c304 /clang/lib/Frontend/CompilerInvocation.cpp
parentffe7950ebc62380c3afc7c71f454a1db3f6f5c76 (diff)
downloadllvm-24bd47dc172f5dc81de7baac880c55b1e615fa70.zip
llvm-24bd47dc172f5dc81de7baac880c55b1e615fa70.tar.gz
llvm-24bd47dc172f5dc81de7baac880c55b1e615fa70.tar.bz2
[analyzer][NFC] Inline AnalyzerOptions::getUserMode()
When I read the code I found it easier to reason about if `getUserMode` is inlined. It might be a personal preference though. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127486
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index e093582..deec3e8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1089,25 +1089,22 @@ static void initOption(AnalyzerOptions::ConfigTable &Config,
static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
DiagnosticsEngine *Diags) {
// TODO: There's no need to store the entire configtable, it'd be plenty
- // enough tostore checker options.
+ // enough to store checker options.
#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \
initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEFAULT_VAL);
+#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(...)
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
-#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \
- SHALLOW_VAL, DEEP_VAL) \
- switch (AnOpts.getUserMode()) { \
- case UMK_Shallow: \
- initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, SHALLOW_VAL); \
- break; \
- case UMK_Deep: \
- initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEEP_VAL); \
- break; \
- } \
+ assert(AnOpts.UserMode == "shallow" || AnOpts.UserMode == "deep");
+ const bool InShallowMode = AnOpts.UserMode == "shallow";
+#define ANALYZER_OPTION(...)
+#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \
+ SHALLOW_VAL, DEEP_VAL) \
+ initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, \
+ InShallowMode ? SHALLOW_VAL : DEEP_VAL);
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
-#undef ANALYZER_OPTION
-#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
// At this point, AnalyzerOptions is configured. Let's validate some options.