mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 07:17:32 +00:00
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
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "TGLexer.h"
|
#include "TGLexer.h"
|
||||||
|
#include "TGSourceMgr.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@@ -23,18 +24,13 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
TGLexer::TGLexer(MemoryBuffer *StartBuf) : CurLineNo(1), CurBuf(StartBuf) {
|
TGLexer::TGLexer(TGSourceMgr &SM) : SrcMgr(SM) {
|
||||||
|
CurBuffer = 0;
|
||||||
|
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
|
||||||
CurPtr = CurBuf->getBufferStart();
|
CurPtr = CurBuf->getBufferStart();
|
||||||
TokStart = 0;
|
TokStart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TGLexer::~TGLexer() {
|
|
||||||
while (!IncludeStack.empty()) {
|
|
||||||
delete IncludeStack.back().Buffer;
|
|
||||||
IncludeStack.pop_back();
|
|
||||||
}
|
|
||||||
delete CurBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ReturnError - Set the error to the specified string at the specified
|
/// ReturnError - Set the error to the specified string at the specified
|
||||||
/// location. This is defined to always return tgtok::Error.
|
/// location. This is defined to always return tgtok::Error.
|
||||||
@@ -43,36 +39,9 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
|||||||
return tgtok::Error;
|
return tgtok::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGLexer::PrintIncludeStack(std::ostream &OS) const {
|
|
||||||
for (unsigned i = 0, e = IncludeStack.size(); i != e; ++i)
|
|
||||||
OS << "Included from " << IncludeStack[i].Buffer->getBufferIdentifier()
|
|
||||||
<< ":" << IncludeStack[i].LineNo << ":\n";
|
|
||||||
OS << "Parsing " << CurBuf->getBufferIdentifier() << ":"
|
|
||||||
<< CurLineNo << ": ";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// PrintError - Print the error at the specified location.
|
void TGLexer::PrintError(LocTy Loc, const std::string &Msg) const {
|
||||||
void TGLexer::PrintError(const char *ErrorLoc, const std::string &Msg) const {
|
SrcMgr.PrintError(Loc, Msg);
|
||||||
PrintIncludeStack(*cerr.stream());
|
|
||||||
cerr << Msg << "\n";
|
|
||||||
assert(ErrorLoc && "Location not specified!");
|
|
||||||
|
|
||||||
// Scan backward to find the start of the line.
|
|
||||||
const char *LineStart = ErrorLoc;
|
|
||||||
while (LineStart != CurBuf->getBufferStart() &&
|
|
||||||
LineStart[-1] != '\n' && LineStart[-1] != '\r')
|
|
||||||
--LineStart;
|
|
||||||
// Get the end of the line.
|
|
||||||
const char *LineEnd = ErrorLoc;
|
|
||||||
while (LineEnd != CurBuf->getBufferEnd() &&
|
|
||||||
LineEnd[0] != '\n' && LineEnd[0] != '\r')
|
|
||||||
++LineEnd;
|
|
||||||
// Print out the line.
|
|
||||||
cerr << std::string(LineStart, LineEnd) << "\n";
|
|
||||||
// Print out spaces before the carat.
|
|
||||||
for (const char *Pos = LineStart; Pos != ErrorLoc; ++Pos)
|
|
||||||
cerr << (*Pos == '\t' ? '\t' : ' ');
|
|
||||||
cerr << "^\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TGLexer::getNextChar() {
|
int TGLexer::getNextChar() {
|
||||||
@@ -80,7 +49,7 @@ int TGLexer::getNextChar() {
|
|||||||
switch (CurChar) {
|
switch (CurChar) {
|
||||||
default:
|
default:
|
||||||
return (unsigned char)CurChar;
|
return (unsigned char)CurChar;
|
||||||
case 0:
|
case 0: {
|
||||||
// A nul character in the stream is either the end of the current buffer or
|
// A nul character in the stream is either the end of the current buffer or
|
||||||
// a random nul in the file. Disambiguate that here.
|
// a random nul in the file. Disambiguate that here.
|
||||||
if (CurPtr-1 != CurBuf->getBufferEnd())
|
if (CurPtr-1 != CurBuf->getBufferEnd())
|
||||||
@@ -88,18 +57,18 @@ int TGLexer::getNextChar() {
|
|||||||
|
|
||||||
// If this is the end of an included file, pop the parent file off the
|
// If this is the end of an included file, pop the parent file off the
|
||||||
// include stack.
|
// include stack.
|
||||||
if (!IncludeStack.empty()) {
|
TGLocTy ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
|
||||||
delete CurBuf;
|
if (ParentIncludeLoc != TGLocTy()) {
|
||||||
CurBuf = IncludeStack.back().Buffer;
|
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
|
||||||
CurLineNo = IncludeStack.back().LineNo;
|
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
|
||||||
CurPtr = IncludeStack.back().CurPtr;
|
CurPtr = ParentIncludeLoc;
|
||||||
IncludeStack.pop_back();
|
|
||||||
return getNextChar();
|
return getNextChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, return end of file.
|
// Otherwise, return end of file.
|
||||||
--CurPtr; // Another call to lex will return EOF again.
|
--CurPtr; // Another call to lex will return EOF again.
|
||||||
return EOF;
|
return EOF;
|
||||||
|
}
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
// Handle the newline character by ignoring it and incrementing the line
|
// Handle the newline character by ignoring it and incrementing the line
|
||||||
@@ -108,8 +77,6 @@ int TGLexer::getNextChar() {
|
|||||||
if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
|
if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
|
||||||
*CurPtr != CurChar)
|
*CurPtr != CurChar)
|
||||||
++CurPtr; // Eat the two char newline sequence.
|
++CurPtr; // Eat the two char newline sequence.
|
||||||
|
|
||||||
++CurLineNo;
|
|
||||||
return '\n';
|
return '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,9 +239,8 @@ bool TGLexer::LexInclude() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the line number and lex buffer of the includer.
|
// Save the line number and lex buffer of the includer.
|
||||||
IncludeStack.push_back(IncludeRec(CurBuf, CurPtr, CurLineNo));
|
CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, CurPtr);
|
||||||
|
|
||||||
CurLineNo = 1; // Reset line numbering.
|
|
||||||
CurBuf = NewBuf;
|
CurBuf = NewBuf;
|
||||||
CurPtr = CurBuf->getBufferStart();
|
CurPtr = CurBuf->getBufferStart();
|
||||||
return false;
|
return false;
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MemoryBuffer;
|
class MemoryBuffer;
|
||||||
|
class TGSourceMgr;
|
||||||
|
|
||||||
namespace tgtok {
|
namespace tgtok {
|
||||||
enum TokKind {
|
enum TokKind {
|
||||||
@@ -55,9 +56,10 @@ namespace tgtok {
|
|||||||
|
|
||||||
/// TGLexer - TableGen Lexer class.
|
/// TGLexer - TableGen Lexer class.
|
||||||
class TGLexer {
|
class TGLexer {
|
||||||
|
TGSourceMgr &SrcMgr;
|
||||||
|
|
||||||
const char *CurPtr;
|
const char *CurPtr;
|
||||||
unsigned CurLineNo;
|
const MemoryBuffer *CurBuf;
|
||||||
MemoryBuffer *CurBuf;
|
|
||||||
|
|
||||||
// Information about the current token.
|
// Information about the current token.
|
||||||
const char *TokStart;
|
const char *TokStart;
|
||||||
@@ -65,23 +67,16 @@ class TGLexer {
|
|||||||
std::string CurStrVal; // This is valid for ID, STRVAL, VARNAME, CODEFRAGMENT
|
std::string CurStrVal; // This is valid for ID, STRVAL, VARNAME, CODEFRAGMENT
|
||||||
int64_t CurIntVal; // This is valid for INTVAL.
|
int64_t CurIntVal; // This is valid for INTVAL.
|
||||||
|
|
||||||
/// IncludeRec / IncludeStack - This captures the current set of include
|
/// CurBuffer - This is the current buffer index we're lexing from as managed
|
||||||
/// directives we are nested within.
|
/// by the SourceMgr object.
|
||||||
struct IncludeRec {
|
int CurBuffer;
|
||||||
MemoryBuffer *Buffer;
|
|
||||||
const char *CurPtr;
|
|
||||||
unsigned LineNo;
|
|
||||||
IncludeRec(MemoryBuffer *buffer, const char *curPtr, unsigned lineNo)
|
|
||||||
: Buffer(buffer), CurPtr(curPtr), LineNo(lineNo) {}
|
|
||||||
};
|
|
||||||
std::vector<IncludeRec> IncludeStack;
|
|
||||||
|
|
||||||
// IncludeDirectories - This is the list of directories we should search for
|
// IncludeDirectories - This is the list of directories we should search for
|
||||||
// include files in.
|
// include files in.
|
||||||
std::vector<std::string> IncludeDirectories;
|
std::vector<std::string> IncludeDirectories;
|
||||||
public:
|
public:
|
||||||
TGLexer(MemoryBuffer *StartBuf);
|
TGLexer(TGSourceMgr &SrcMgr);
|
||||||
~TGLexer();
|
~TGLexer() {}
|
||||||
|
|
||||||
void setIncludeDirs(const std::vector<std::string> &Dirs) {
|
void setIncludeDirs(const std::vector<std::string> &Dirs) {
|
||||||
IncludeDirectories = Dirs;
|
IncludeDirectories = Dirs;
|
||||||
@@ -109,8 +104,6 @@ public:
|
|||||||
|
|
||||||
void PrintError(LocTy Loc, const std::string &Msg) const;
|
void PrintError(LocTy Loc, const std::string &Msg) const;
|
||||||
|
|
||||||
void PrintIncludeStack(std::ostream &OS) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// LexToken - Read the next token and return its code.
|
/// LexToken - Read the next token and return its code.
|
||||||
tgtok::TokKind LexToken();
|
tgtok::TokKind LexToken();
|
||||||
|
@@ -47,7 +47,7 @@ class TGParser {
|
|||||||
public:
|
public:
|
||||||
typedef TGLexer::LocTy LocTy;
|
typedef TGLexer::LocTy LocTy;
|
||||||
|
|
||||||
TGParser(MemoryBuffer *StartBuf) : Lex(StartBuf), CurMultiClass(0) {}
|
TGParser(TGSourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {}
|
||||||
|
|
||||||
void setIncludeDirs(const std::vector<std::string> &D){Lex.setIncludeDirs(D);}
|
void setIncludeDirs(const std::vector<std::string> &D){Lex.setIncludeDirs(D);}
|
||||||
|
|
||||||
|
104
utils/TableGen/TGSourceMgr.cpp
Normal file
104
utils/TableGen/TGSourceMgr.cpp
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
//===- TGSourceMgr.cpp - Manager for Source Buffers & Diagnostics ---------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file implements the TGSourceMgr class.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "TGSourceMgr.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
TGSourceMgr::~TGSourceMgr() {
|
||||||
|
while (!Buffers.empty()) {
|
||||||
|
delete Buffers.back().Buffer;
|
||||||
|
Buffers.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FindBufferContainingLoc - Return the ID of the buffer containing the
|
||||||
|
/// specified location, returning -1 if not found.
|
||||||
|
int TGSourceMgr::FindBufferContainingLoc(TGLocTy Loc) const {
|
||||||
|
for (unsigned i = 0, e = Buffers.size(); i != e; ++i)
|
||||||
|
if (Loc >= Buffers[i].Buffer->getBufferStart() &&
|
||||||
|
Loc < Buffers[i].Buffer->getBufferEnd())
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FindLineNumber - Find the line number for the specified location in the
|
||||||
|
/// specified file. This is not a fast method.
|
||||||
|
unsigned TGSourceMgr::FindLineNumber(TGLocTy Loc, int BufferID) const {
|
||||||
|
if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc);
|
||||||
|
assert(BufferID != -1 && "Invalid Location!");
|
||||||
|
|
||||||
|
MemoryBuffer *Buff = getBufferInfo(BufferID).Buffer;
|
||||||
|
|
||||||
|
// Count the number of \n's between the start of the file and the specified
|
||||||
|
// location.
|
||||||
|
unsigned LineNo = 1;
|
||||||
|
|
||||||
|
const char *Ptr = Buff->getBufferStart();
|
||||||
|
|
||||||
|
for (; Ptr != Loc; ++Ptr)
|
||||||
|
if (*Ptr == '\n') ++LineNo;
|
||||||
|
return LineNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TGSourceMgr::PrintIncludeStack(TGLocTy IncludeLoc) const {
|
||||||
|
if (IncludeLoc == TGLocTy()) return; // Top of stack.
|
||||||
|
|
||||||
|
int CurBuf = FindBufferContainingLoc(IncludeLoc);
|
||||||
|
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
||||||
|
|
||||||
|
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
|
||||||
|
|
||||||
|
errs() << "Included from "
|
||||||
|
<< getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
|
||||||
|
<< ":" << FindLineNumber(IncludeLoc, CurBuf) << ":\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TGSourceMgr::PrintError(TGLocTy ErrorLoc, const std::string &Msg) const {
|
||||||
|
raw_ostream &OS = errs();
|
||||||
|
|
||||||
|
// First thing to do: find the current buffer containing the specified
|
||||||
|
// location.
|
||||||
|
int CurBuf = FindBufferContainingLoc(ErrorLoc);
|
||||||
|
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
||||||
|
|
||||||
|
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
|
||||||
|
|
||||||
|
MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
|
||||||
|
|
||||||
|
|
||||||
|
OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
|
||||||
|
<< FindLineNumber(ErrorLoc, CurBuf) << ": ";
|
||||||
|
|
||||||
|
OS << Msg << "\n";
|
||||||
|
assert(ErrorLoc && "Location not specified!");
|
||||||
|
|
||||||
|
// Scan backward to find the start of the line.
|
||||||
|
const char *LineStart = ErrorLoc;
|
||||||
|
while (LineStart != CurMB->getBufferStart() &&
|
||||||
|
LineStart[-1] != '\n' && LineStart[-1] != '\r')
|
||||||
|
--LineStart;
|
||||||
|
// Get the end of the line.
|
||||||
|
const char *LineEnd = ErrorLoc;
|
||||||
|
while (LineEnd != CurMB->getBufferEnd() &&
|
||||||
|
LineEnd[0] != '\n' && LineEnd[0] != '\r')
|
||||||
|
++LineEnd;
|
||||||
|
// Print out the line.
|
||||||
|
OS << std::string(LineStart, LineEnd) << "\n";
|
||||||
|
// Print out spaces before the carat.
|
||||||
|
for (const char *Pos = LineStart; Pos != ErrorLoc; ++Pos)
|
||||||
|
OS << (*Pos == '\t' ? '\t' : ' ');
|
||||||
|
OS << "^\n";
|
||||||
|
}
|
88
utils/TableGen/TGSourceMgr.h
Normal file
88
utils/TableGen/TGSourceMgr.h
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
//===- TGSourceMgr.h - Manager for Source Buffers & Diagnostics -*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file declares the TGSourceMgr class.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef TGSOURCEMGR_H
|
||||||
|
#define TGSOURCEMGR_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
class MemoryBuffer;
|
||||||
|
|
||||||
|
/// FIXME: Make this a struct that is opaque.
|
||||||
|
typedef const char *TGLocTy;
|
||||||
|
|
||||||
|
/// TGSourceMgr - This owns the files read by tblgen, handles include stacks,
|
||||||
|
/// and handles printing of diagnostics.
|
||||||
|
class TGSourceMgr {
|
||||||
|
struct SrcBuffer {
|
||||||
|
/// Buffer - The memory buffer for the file.
|
||||||
|
MemoryBuffer *Buffer;
|
||||||
|
|
||||||
|
/// IncludeLoc - This is the location of the parent include, or null if at
|
||||||
|
/// the top level.
|
||||||
|
TGLocTy IncludeLoc;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Buffers - This is all of the buffers that we are reading from.
|
||||||
|
std::vector<SrcBuffer> Buffers;
|
||||||
|
|
||||||
|
TGSourceMgr(const TGSourceMgr&); // DO NOT IMPLEMENT
|
||||||
|
void operator=(const TGSourceMgr&); // DO NOT IMPLEMENT
|
||||||
|
public:
|
||||||
|
TGSourceMgr() {}
|
||||||
|
~TGSourceMgr();
|
||||||
|
|
||||||
|
const SrcBuffer &getBufferInfo(unsigned i) const {
|
||||||
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
|
return Buffers[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MemoryBuffer *getMemoryBuffer(unsigned i) const {
|
||||||
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
|
return Buffers[i].Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
TGLocTy getParentIncludeLoc(unsigned i) const {
|
||||||
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
|
return Buffers[i].IncludeLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned AddNewSourceBuffer(MemoryBuffer *F, TGLocTy IncludeLoc) {
|
||||||
|
SrcBuffer NB;
|
||||||
|
NB.Buffer = F;
|
||||||
|
NB.IncludeLoc = IncludeLoc;
|
||||||
|
Buffers.push_back(NB);
|
||||||
|
return Buffers.size()-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// FindBufferContainingLoc - Return the ID of the buffer containing the
|
||||||
|
/// specified location, returning -1 if not found.
|
||||||
|
int FindBufferContainingLoc(TGLocTy Loc) const;
|
||||||
|
|
||||||
|
/// FindLineNumber - Find the line number for the specified location in the
|
||||||
|
/// specified file. This is not a fast method.
|
||||||
|
unsigned FindLineNumber(TGLocTy Loc, int BufferID = -1) const;
|
||||||
|
|
||||||
|
|
||||||
|
/// PrintError - Emit an error message about the specified location with the
|
||||||
|
/// specified string.
|
||||||
|
void PrintError(TGLocTy ErrorLoc, const std::string &Msg) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void PrintIncludeStack(TGLocTy IncludeLoc) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end llvm namespace
|
||||||
|
|
||||||
|
#endif
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
#include "TGParser.h"
|
#include "TGParser.h"
|
||||||
|
#include "TGSourceMgr.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
@@ -113,7 +114,8 @@ RecordKeeper llvm::Records;
|
|||||||
/// ParseFile - this function begins the parsing of the specified tablegen
|
/// ParseFile - this function begins the parsing of the specified tablegen
|
||||||
/// file.
|
/// file.
|
||||||
static bool ParseFile(const std::string &Filename,
|
static bool ParseFile(const std::string &Filename,
|
||||||
const std::vector<std::string> &IncludeDirs) {
|
const std::vector<std::string> &IncludeDirs,
|
||||||
|
TGSourceMgr &SrcMgr) {
|
||||||
std::string ErrorStr;
|
std::string ErrorStr;
|
||||||
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
|
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
|
||||||
if (F == 0) {
|
if (F == 0) {
|
||||||
@@ -121,7 +123,10 @@ static bool ParseFile(const std::string &Filename,
|
|||||||
return true;
|
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
|
// Record the location of the include directory so that the lexer can find
|
||||||
// it later.
|
// it later.
|
||||||
@@ -135,8 +140,10 @@ int main(int argc, char **argv) {
|
|||||||
PrettyStackTraceProgram X(argc, argv);
|
PrettyStackTraceProgram X(argc, argv);
|
||||||
cl::ParseCommandLineOptions(argc, argv);
|
cl::ParseCommandLineOptions(argc, argv);
|
||||||
|
|
||||||
|
TGSourceMgr SrcMgr;
|
||||||
|
|
||||||
// Parse the input file.
|
// Parse the input file.
|
||||||
if (ParseFile(InputFilename, IncludeDirs))
|
if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
std::ostream *Out = cout.stream();
|
std::ostream *Out = cout.stream();
|
||||||
|
Reference in New Issue
Block a user