Use `constexpr` for more constants in `libdexfile/dex/dex_file.h`.
Use `static constexpr` instead of `static const` for more constants in
this file, to avoid missing definition issues in some compilation
setups, like ART code coverage build configurations.
Test: build/soong/soong_ui.bash --make-mode \
TARGET_PRODUCT=aosp_cf_x86_phone \
TARGET_BUILD_VARIANT=userdebug \
EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true \
JAVA_COVERAGE_PATHS=art \
CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS=art \
com.android.art.debug
Bug: 152402333
Change-Id: Ib9da1a9043b71d56673fcec7e9dab4718310e254
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index 649ee0c..a21e538 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -77,14 +77,14 @@
static constexpr size_t kDexVersionLen = 4;
// First Dex format version enforcing class definition ordering rules.
- static const uint32_t kClassDefinitionOrderEnforcedVersion = 37;
+ static constexpr uint32_t kClassDefinitionOrderEnforcedVersion = 37;
static constexpr size_t kSha1DigestSize = 20;
static constexpr uint32_t kDexEndianConstant = 0x12345678;
// The value of an invalid index.
- static const uint16_t kDexNoIndex16 = 0xFFFF;
- static const uint32_t kDexNoIndex32 = 0xFFFFFFFF;
+ static constexpr uint16_t kDexNoIndex16 = 0xFFFF;
+ static constexpr uint32_t kDexNoIndex32 = 0xFFFFFFFF;
// Raw header_item.
struct Header {
@@ -789,7 +789,7 @@
protected:
// First Dex format version supporting default methods.
- static const uint32_t kDefaultMethodsVersion = 37;
+ static constexpr uint32_t kDefaultMethodsVersion = 37;
DexFile(const uint8_t* base,
size_t size,