summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2017-08-08 18:49:59 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-08-08 18:49:59 +0000
commita97a14fa206bc8175d785c7fb1ee4e81ec4d100d (patch)
tree883429553c5b68328ab40ec9049ff0cccb2ee9f0
parent24be74dbffea935fa1f07d112611fa03d4f3e6af (diff)
parentf573972a087b798f74bf5404e271355a2805e100 (diff)
Merge "runtime: Make kIsDebugBuild friendly to clion"
-rw-r--r--runtime/globals.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/globals.h b/runtime/globals.h
index 616422585e..256306d1de 100644
--- a/runtime/globals.h
+++ b/runtime/globals.h
@@ -51,11 +51,17 @@ static constexpr size_t kObjectAlignmentShift = 3;
static constexpr size_t kObjectAlignment = 1u << kObjectAlignmentShift;
static constexpr size_t kLargeObjectAlignment = kPageSize;
+// Clion, clang analyzer, etc can falsely believe that "if (kIsDebugBuild)" always
+// returns the same value. By wrapping into a call to another constexpr function, we force it
+// to realize that is not actually always evaluating to the same value.
+static constexpr bool GlobalsReturnSelf(bool self) { return self; }
+
// Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't.
-#if defined(NDEBUG)
-static constexpr bool kIsDebugBuild = false;
+// TODO: Use only __clang_analyzer__ here. b/64455231
+#if defined(NDEBUG) && !defined(__CLION_IDE__)
+static constexpr bool kIsDebugBuild = GlobalsReturnSelf(false);
#else
-static constexpr bool kIsDebugBuild = true;
+static constexpr bool kIsDebugBuild = GlobalsReturnSelf(true);
#endif
// ART_TARGET - Defined for target builds of ART.