summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-27 20:04:08 +0000
committerChris Lattner <sabre@nondot.org>2009-04-27 20:04:08 +0000
commit0e3f50d8cf054c84c8ac95f7cab20996f985056f (patch)
tree9379f9913446f5951a922316fd64c732ccbd31a1
parent7ca3521d6af5ba19dc671ffa4fb5840c12264f67 (diff)
downloadbcm5719-llvm-0e3f50d8cf054c84c8ac95f7cab20996f985056f.tar.gz
bcm5719-llvm-0e3f50d8cf054c84c8ac95f7cab20996f985056f.zip
give bitstreamreader an API to ignore names for blocks/records,
only llvm-bcanalyzer wants this info. llvm-svn: 70239
-rw-r--r--llvm/include/llvm/Bitcode/BitstreamReader.h17
-rw-r--r--llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp1
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/Bitcode/BitstreamReader.h b/llvm/include/llvm/Bitcode/BitstreamReader.h
index be3d8c55b7a..b7ae47d1e62 100644
--- a/llvm/include/llvm/Bitcode/BitstreamReader.h
+++ b/llvm/include/llvm/Bitcode/BitstreamReader.h
@@ -41,11 +41,19 @@ private:
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:
- BitstreamReader() : FirstChar(0), LastChar(0) {
+ BitstreamReader() : FirstChar(0), LastChar(0), IgnoreBlockInfoNames(true) {
}
BitstreamReader(const unsigned char *Start, const unsigned char *End) {
+ IgnoreBlockInfoNames = true;
init(Start, End);
}
@@ -70,6 +78,11 @@ public:
const unsigned char *getFirstChar() const { return FirstChar; }
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
//===--------------------------------------------------------------------===//
@@ -598,6 +611,7 @@ public:
break;
case bitc::BLOCKINFO_CODE_BLOCKNAME: {
if (!CurBlockInfo) return true;
+ if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
std::string Name;
for (unsigned i = 0, e = Record.size(); i != e; ++i)
Name += (char)Record[i];
@@ -606,6 +620,7 @@ public:
}
case bitc::BLOCKINFO_CODE_SETRECORDNAME: {
if (!CurBlockInfo) return true;
+ if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
std::string Name;
for (unsigned i = 1, e = Record.size(); i != e; ++i)
Name += (char)Record[i];
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index 9c5a3ae8ae3..e5955c74809 100644
--- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -464,6 +464,7 @@ static int AnalyzeBitcode() {
BitstreamReader StreamFile(BufPtr, EndBufPtr);
BitstreamCursor Stream(StreamFile);
+ StreamFile.CollectBlockInfoNames();
// Read the stream signature.
char Signature[6];
OpenPOWER on IntegriCloud