[cfe-commits] r144115 - in /cfe/trunk: include/clang/Frontend/SerializedDiagnosticPrinter.h lib/Frontend/SerializedDiagnosticPrinter.cpp
Ted Kremenek
kremenek at apple.com
Tue Nov 8 12:27:29 PST 2011
Author: kremenek
Date: Tue Nov 8 14:27:29 2011
New Revision: 144115
URL: http://llvm.org/viewvc/llvm-project?rev=144115&view=rev
Log:
serialized diagnostics: serialize the version info in a separate meta block.
Modified:
cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
Modified: cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h?rev=144115&r1=144114&r2=144115&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h Tue Nov 8 14:27:29 2011
@@ -23,12 +23,18 @@
namespace serialized_diags {
enum BlockIDs {
- /// \brief The DIAG block, which acts as a container around a diagnostic.
- BLOCK_DIAG = llvm::bitc::FIRST_APPLICATION_BLOCKID
+ /// \brief A top-level block which represents any meta data associated
+ /// with the diagostics, including versioning of the format.
+ BLOCK_META = llvm::bitc::FIRST_APPLICATION_BLOCKID,
+
+ /// \brief The this block acts as a container for all the information
+ /// for a specific diagnostic.
+ BLOCK_DIAG
};
enum RecordIDs {
- RECORD_DIAG = 1,
+ RECORD_VERSION = 1,
+ RECORD_DIAG,
RECORD_SOURCE_RANGE,
RECORD_DIAG_FLAG,
RECORD_CATEGORY,
Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=144115&r1=144114&r2=144115&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Tue Nov 8 14:27:29 2011
@@ -22,20 +22,6 @@
using namespace clang::serialized_diags;
namespace {
-
-/// \brief A utility class for entering and exiting bitstream blocks.
-class BlockEnterExit {
- llvm::BitstreamWriter &Stream;
-public:
- BlockEnterExit(llvm::BitstreamWriter &stream, unsigned blockID,
- unsigned codelen = 3)
- : Stream(stream) {
- Stream.EnterSubblock(blockID, codelen);
- }
- ~BlockEnterExit() {
- Stream.ExitBlock();
- }
-};
class AbbreviationMap {
llvm::DenseMap<unsigned, unsigned> Abbrevs;
@@ -85,6 +71,9 @@
/// \brief Emit the BLOCKINFO block.
void EmitBlockInfoBlock();
+ /// \brief Emit the META data block.
+ void EmitMetaBlock();
+
/// \brief Emit a record for a CharSourceRange.
void EmitCharSourceRange(CharSourceRange R);
@@ -257,9 +246,12 @@
void SDiagsWriter::EmitPreamble() {
// Emit the file header.
Stream.Emit((unsigned)'D', 8);
- Stream.Emit((unsigned) Version, 32 - 8);
+ Stream.Emit((unsigned)'I', 8);
+ Stream.Emit((unsigned)'A', 8);
+ Stream.Emit((unsigned)'G', 8);
EmitBlockInfoBlock();
+ EmitMetaBlock();
}
static void AddSourceLocationAbbrev(llvm::BitCodeAbbrev *Abbrev) {
@@ -277,7 +269,20 @@
void SDiagsWriter::EmitBlockInfoBlock() {
Stream.EnterBlockInfoBlock(3);
-
+
+ using namespace llvm;
+
+ // ==---------------------------------------------------------------------==//
+ // The subsequent records and Abbrevs are for the "Meta" block.
+ // ==---------------------------------------------------------------------==//
+
+ EmitBlockID(BLOCK_META, "Meta", Stream, Record);
+ EmitRecordID(RECORD_VERSION, "Version", Stream, Record);
+ BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+ Abbrev->Add(BitCodeAbbrevOp(RECORD_VERSION));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
+ Abbrevs.set(RECORD_VERSION, Stream.EmitBlockInfoAbbrev(BLOCK_META, Abbrev));
+
// ==---------------------------------------------------------------------==//
// The subsequent records and Abbrevs are for the "Diagnostic" block.
// ==---------------------------------------------------------------------==//
@@ -290,11 +295,8 @@
EmitRecordID(RECORD_FILENAME, "FileName", Stream, Record);
EmitRecordID(RECORD_FIXIT, "FixIt", Stream, Record);
- // Emit Abbrevs.
- using namespace llvm;
-
// Emit abbreviation for RECORD_DIAG.
- BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+ Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(RECORD_DIAG));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Diag level.
AddSourceLocationAbbrev(Abbrev);
@@ -351,6 +353,15 @@
Stream.ExitBlock();
}
+void SDiagsWriter::EmitMetaBlock() {
+ Stream.EnterSubblock(BLOCK_META, 3);
+ Record.clear();
+ Record.push_back(RECORD_VERSION);
+ Record.push_back(Version);
+ Stream.EmitRecordWithAbbrev(Abbrevs.get(RECORD_VERSION), Record);
+ Stream.ExitBlock();
+}
+
unsigned SDiagsWriter::getEmitCategory(unsigned int DiagID) {
unsigned category = DiagnosticIDs::getCategoryNumberForDiag(DiagID);
More information about the cfe-commits
mailing list