give bitstreamreader an API to ignore names for blocks/records,

only llvm-bcanalyzer wants this info.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70239 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-04-27 20:04:08 +00:00
parent 82fd3f3d3a
commit 0370cc6399
2 changed files with 17 additions and 1 deletions

View File

@@ -41,11 +41,19 @@ private:
std::vector<BlockInfo> BlockInfoRecords; std::vector<BlockInfo> BlockInfoRecords;
/// IgnoreBlockInfoNames - This is set to true if we don't care about the
/// block/record name information in the BlockInfo block. Only llvm-bcanalyzer
/// uses this.
bool IgnoreBlockInfoNames;
BitstreamReader(const BitstreamReader&); // NOT IMPLEMENTED
void operator=(const BitstreamReader&); // NOT IMPLEMENTED
public: public:
BitstreamReader() : FirstChar(0), LastChar(0) { BitstreamReader() : FirstChar(0), LastChar(0), IgnoreBlockInfoNames(true) {
} }
BitstreamReader(const unsigned char *Start, const unsigned char *End) { BitstreamReader(const unsigned char *Start, const unsigned char *End) {
IgnoreBlockInfoNames = true;
init(Start, End); init(Start, End);
} }
@@ -70,6 +78,11 @@ public:
const unsigned char *getFirstChar() const { return FirstChar; } const unsigned char *getFirstChar() const { return FirstChar; }
const unsigned char *getLastChar() const { return LastChar; } const unsigned char *getLastChar() const { return LastChar; }
/// CollectBlockInfoNames - This is called by clients that want block/record
/// name information.
void CollectBlockInfoNames() { IgnoreBlockInfoNames = false; }
bool isIgnoringBlockInfoNames() { return IgnoreBlockInfoNames; }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Block Manipulation // Block Manipulation
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@@ -598,6 +611,7 @@ public:
break; break;
case bitc::BLOCKINFO_CODE_BLOCKNAME: { case bitc::BLOCKINFO_CODE_BLOCKNAME: {
if (!CurBlockInfo) return true; if (!CurBlockInfo) return true;
if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
std::string Name; std::string Name;
for (unsigned i = 0, e = Record.size(); i != e; ++i) for (unsigned i = 0, e = Record.size(); i != e; ++i)
Name += (char)Record[i]; Name += (char)Record[i];
@@ -606,6 +620,7 @@ public:
} }
case bitc::BLOCKINFO_CODE_SETRECORDNAME: { case bitc::BLOCKINFO_CODE_SETRECORDNAME: {
if (!CurBlockInfo) return true; if (!CurBlockInfo) return true;
if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
std::string Name; std::string Name;
for (unsigned i = 1, e = Record.size(); i != e; ++i) for (unsigned i = 1, e = Record.size(); i != e; ++i)
Name += (char)Record[i]; Name += (char)Record[i];

View File

@@ -464,6 +464,7 @@ static int AnalyzeBitcode() {
BitstreamReader StreamFile(BufPtr, EndBufPtr); BitstreamReader StreamFile(BufPtr, EndBufPtr);
BitstreamCursor Stream(StreamFile); BitstreamCursor Stream(StreamFile);
StreamFile.CollectBlockInfoNames();
// Read the stream signature. // Read the stream signature.
char Signature[6]; char Signature[6];