[PATCH] D19975: [scan-build] fix warning emitted on LLVM Bitcode code base

Apelete Seketeli via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 15:48:53 PDT 2016


apelete updated this revision to Diff 56361.
apelete added a comment.

[scan-build] fix warning emitted on LLVM Bitcode code base

Changes since last revision:

- initialize FnEntry8BitAbbrev, FnEntry7BitAbbrev and FnEntry6BitAbbrev variables to 0 and assert they are non-zero prior being read.


http://reviews.llvm.org/D19975

Files:
  lib/Bitcode/Writer/BitcodeWriter.cpp

Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2507,9 +2507,9 @@
 
   // For the module-level VST, add abbrev Ids for the VST_CODE_FNENTRY
   // records, which are not used in the per-function VSTs.
-  unsigned FnEntry8BitAbbrev;
-  unsigned FnEntry7BitAbbrev;
-  unsigned FnEntry6BitAbbrev;
+  unsigned FnEntry8BitAbbrev = 0;
+  unsigned FnEntry7BitAbbrev = 0;
+  unsigned FnEntry6BitAbbrev = 0;
   if (IsModuleLevel && hasVSTOffsetPlaceholder()) {
     // 8-bit fixed-width VST_CODE_FNENTRY function strings.
     BitCodeAbbrev *Abbv = new BitCodeAbbrev();
@@ -2582,11 +2582,15 @@
       NameVals.push_back(BitcodeIndex / 32);
 
       Code = bitc::VST_CODE_FNENTRY;
+      assert(FnEntry8BitAbbrev && "abbrev was not computed");
       AbbrevToUse = FnEntry8BitAbbrev;
-      if (Bits == SE_Char6)
+      if (Bits == SE_Char6) {
+        assert(FnEntry6BitAbbrev && "abbrev was not computed");
         AbbrevToUse = FnEntry6BitAbbrev;
-      else if (Bits == SE_Fixed7)
+      } else if (Bits == SE_Fixed7) {
+        assert(FnEntry7BitAbbrev && "abbrev was not computed");
         AbbrevToUse = FnEntry7BitAbbrev;
+      }
     } else {
       Code = bitc::VST_CODE_ENTRY;
       if (Bits == SE_Char6)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19975.56361.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160505/5c3bffc3/attachment.bin>


More information about the llvm-commits mailing list