aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/TableGen.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-13 07:05:43 +0000
committerChris Lattner <sabre@nondot.org>2009-03-13 07:05:43 +0000
commitaa739d26b1e65aec7f9afa1cde7e069c081ea355 (patch)
tree47022e6176ab05e1d1efdb65d81a29fff79e07ba /utils/TableGen/TableGen.cpp
parent49c8aa0d8b2824c70d178c5d55cda64d6613c0d8 (diff)
split buffer management and diagnostic printing out of the tblgen
lexer into its own TGSourceMgr class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/TableGen.cpp')
-rw-r--r--utils/TableGen/TableGen.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index 147db12cf1..c6a1f2e4ab 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -17,6 +17,7 @@
#include "Record.h"
#include "TGParser.h"
+#include "TGSourceMgr.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/Signals.h"
@@ -113,15 +114,19 @@ RecordKeeper llvm::Records;
/// ParseFile - this function begins the parsing of the specified tablegen
/// file.
static bool ParseFile(const std::string &Filename,
- const std::vector<std::string> &IncludeDirs) {
+ const std::vector<std::string> &IncludeDirs,
+ TGSourceMgr &SrcMgr) {
std::string ErrorStr;
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
if (F == 0) {
cerr << "Could not open input file '" + Filename + "': " << ErrorStr <<"\n";
return true;
}
-
- TGParser Parser(F);
+
+ // Tell SrcMgr about this buffer, which is what TGParser will pick up.
+ SrcMgr.AddNewSourceBuffer(F, TGLocTy());
+
+ TGParser Parser(SrcMgr);
// Record the location of the include directory so that the lexer can find
// it later.
@@ -135,8 +140,10 @@ int main(int argc, char **argv) {
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
+ TGSourceMgr SrcMgr;
+
// Parse the input file.
- if (ParseFile(InputFilename, IncludeDirs))
+ if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
return 1;
std::ostream *Out = cout.stream();