diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-09-12 16:10:24 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-09-12 16:10:24 +0000 |
commit | 7eea0b9b3638617cdeb85fbb568088d5df7f9816 (patch) | |
tree | edc010bc2fb2ead1ad51637ec298df3b652bb412 | |
parent | b04eee5236f8a99d7d7ac1a896367c0e536b565a (diff) | |
download | bcm5719-llvm-7eea0b9b3638617cdeb85fbb568088d5df7f9816.tar.gz bcm5719-llvm-7eea0b9b3638617cdeb85fbb568088d5df7f9816.zip |
Statically assert that enum items don't overflow storage.
llvm-svn: 313041
-rw-r--r-- | llvm/include/llvm/DebugInfo/DIContext.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h index d6657b4d8d4..8f96b42ec8f 100644 --- a/llvm/include/llvm/DebugInfo/DIContext.h +++ b/llvm/include/llvm/DebugInfo/DIContext.h @@ -112,7 +112,6 @@ struct DILineInfoSpecifier { : FLIKind(FLIKind), FNKind(FNKind) {} }; -namespace { /// This is just a helper to programmatically construct DIDumpType. enum DIDumpTypeCounter { DIDT_ID_Null = 0, @@ -120,15 +119,16 @@ enum DIDumpTypeCounter { DIDT_ID##ENUM_NAME, #include "llvm/BinaryFormat/Dwarf.def" #undef HANDLE_DWARF_SECTION + DIDT_ID_Count, }; -} + static_assert(DIDT_ID_Count <= 64, "section types overflow storage"); /// Selects which debug sections get dumped. enum DIDumpType : uint64_t { DIDT_Null, DIDT_All = ~0ULL, #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \ - DIDT_##ENUM_NAME = 1 << DIDT_ID##ENUM_NAME, + DIDT_##ENUM_NAME = 1 << (DIDT_ID##ENUM_NAME - 1), #include "llvm/BinaryFormat/Dwarf.def" #undef HANDLE_DWARF_SECTION }; |