Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h

Issue 1146203003: Fix abbreviation handling in munged bitcode writer. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Don't allow application of abbreviation if index out of range. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
diff --git a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
index e3e84e672b35929b1b4778028f45395861ddfad1..2deec63a97aa52d620da33124e3f836dcc968b99 100644
--- a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
+++ b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
@@ -421,11 +421,19 @@ private:
public:
- /// Returns true if the given abbreviation index corresponds to a user-defined
- /// abbreviation.
- bool isUserRecordAbbreviation(unsigned Abbrev) const {
- return Abbrev >= naclbitc::FIRST_APPLICATION_ABBREV
- && Abbrev < (CurAbbrevs.size() + naclbitc::FIRST_APPLICATION_ABBREV);
+ /// Returns a pointer to the abbreviation currently associated with
+ // the abbreviation index. Returns nullptr if no such abbreviation
jvoung (off chromium) 2015/05/20 22:40:09 slash consistency /// vs // period
Karl 2015/05/21 18:22:07 Done.
+ const NaClBitCodeAbbrev *getAbbreviation(unsigned Index) const {
+ if (Index < naclbitc::FIRST_APPLICATION_ABBREV)
+ return nullptr;
+ unsigned AbbrevNo = Index - naclbitc::FIRST_APPLICATION_ABBREV;
+ if (AbbrevNo >= CurAbbrevs.size())
+ return nullptr;
+ return CurAbbrevs[AbbrevNo];
+ }
+
+ size_t getCurNumAbbreviations() const {
jvoung (off chromium) 2015/05/20 22:40:09 unused method ?
Karl 2015/05/21 18:22:07 Removed.
+ return CurAbbrevs.size();
}
/// EmitRecord - Emit the specified record to the stream, using an abbrev if

Powered by Google App Engine
This is Rietveld 408576698