diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/AsmWriterEmitter.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/CodeGenInstruction.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/CodeGenRegisters.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/DisassemblerEmitter.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/Error.cpp | 39 | ||||
-rw-r--r-- | utils/TableGen/Error.h | 43 | ||||
-rw-r--r-- | utils/TableGen/FastISelEmitter.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/NeonEmitter.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/Record.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/Record.h | 14 | ||||
-rw-r--r-- | utils/TableGen/SetTheory.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/TGLexer.cpp | 12 | ||||
-rw-r--r-- | utils/TableGen/TGLexer.h | 3 | ||||
-rw-r--r-- | utils/TableGen/TGParser.h | 3 | ||||
-rw-r--r-- | utils/TableGen/TableGen.cpp | 15 |
17 files changed, 99 insertions, 40 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index bf0690f..a05867b 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -98,6 +98,7 @@ #include "AsmMatcherEmitter.h" #include "CodeGenTarget.h" +#include "Error.h" #include "Record.h" #include "StringMatcher.h" #include "llvm/ADT/OwningPtr.h" diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index f3dfb4e..066e03d 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -14,6 +14,7 @@ #include "AsmWriterEmitter.h" #include "AsmWriterInst.h" +#include "Error.h" #include "CodeGenTarget.h" #include "Record.h" #include "StringToOffsetTable.h" diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index a08cde6..1930a96 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "CodeGenDAGPatterns.h" +#include "Error.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 73fe916..e9557d2 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -13,6 +13,7 @@ #include "CodeGenInstruction.h" #include "CodeGenTarget.h" +#include "Error.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" diff --git a/utils/TableGen/CodeGenRegisters.cpp b/utils/TableGen/CodeGenRegisters.cpp index 80765b6..1acf3a8 100644 --- a/utils/TableGen/CodeGenRegisters.cpp +++ b/utils/TableGen/CodeGenRegisters.cpp @@ -14,6 +14,7 @@ #include "CodeGenRegisters.h" #include "CodeGenTarget.h" +#include "Error.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" diff --git a/utils/TableGen/DisassemblerEmitter.cpp b/utils/TableGen/DisassemblerEmitter.cpp index d68d3b0..07313d1 100644 --- a/utils/TableGen/DisassemblerEmitter.cpp +++ b/utils/TableGen/DisassemblerEmitter.cpp @@ -9,6 +9,7 @@ #include "DisassemblerEmitter.h" #include "CodeGenTarget.h" +#include "Error.h" #include "Record.h" #include "X86DisassemblerTables.h" #include "X86RecognizableInstr.h" diff --git a/utils/TableGen/Error.cpp b/utils/TableGen/Error.cpp new file mode 100644 index 0000000..3f6cda8 --- /dev/null +++ b/utils/TableGen/Error.cpp @@ -0,0 +1,39 @@ +//===- Error.cpp - tblgen error handling helper routines --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains error handling helper routines to pretty-print diagnostic +// messages from tblgen. +// +//===----------------------------------------------------------------------===// + +#include "Error.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { + +SourceMgr SrcMgr; + +void PrintError(SMLoc ErrorLoc, const Twine &Msg) { + SrcMgr.PrintMessage(ErrorLoc, Msg, "error"); +} + +void PrintError(const char *Loc, const Twine &Msg) { + SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error"); +} + +void PrintError(const Twine &Msg) { + errs() << "error:" << Msg << "\n"; +} + +void PrintError(const TGError &Error) { + PrintError(Error.getLoc(), Error.getMessage()); +} + +} // end namespace llvm diff --git a/utils/TableGen/Error.h b/utils/TableGen/Error.h new file mode 100644 index 0000000..b3a0146 --- /dev/null +++ b/utils/TableGen/Error.h @@ -0,0 +1,43 @@ +//===- Error.h - tblgen error handling helper routines ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains error handling helper routines to pretty-print diagnostic +// messages from tblgen. +// +//===----------------------------------------------------------------------===// + +#ifndef ERROR_H +#define ERROR_H + +#include "llvm/Support/SourceMgr.h" + +namespace llvm { + +class TGError { + SMLoc Loc; + std::string Message; +public: + TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {} + + SMLoc getLoc() const { return Loc; } + const std::string &getMessage() const { return Message; } +}; + +void PrintError(SMLoc ErrorLoc, const Twine &Msg); +void PrintError(const char *Loc, const Twine &Msg); +void PrintError(const Twine &Msg); +void PrintError(const TGError &Error); + + +extern SourceMgr SrcMgr; + + +} // end namespace "llvm" + +#endif diff --git a/utils/TableGen/FastISelEmitter.cpp b/utils/TableGen/FastISelEmitter.cpp index ef912df..f946ac7 100644 --- a/utils/TableGen/FastISelEmitter.cpp +++ b/utils/TableGen/FastISelEmitter.cpp @@ -18,6 +18,7 @@ //===----------------------------------------------------------------------===// #include "FastISelEmitter.h" +#include "Error.h" #include "Record.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/VectorExtras.h" diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index 23fdbde..ef97744 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -24,6 +24,7 @@ //===----------------------------------------------------------------------===// #include "NeonEmitter.h" +#include "Error.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 8ac8cd9..3c750da 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "Record.h" +#include "Error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Format.h" #include "llvm/ADT/StringExtras.h" diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 522b719..c8905cc 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -1486,22 +1486,8 @@ struct LessRecordFieldName { } }; - -class TGError { - SMLoc Loc; - std::string Message; -public: - TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {} - - SMLoc getLoc() const { return Loc; } - const std::string &getMessage() const { return Message; } -}; - - raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK); -void PrintError(SMLoc ErrorLoc, const Twine &Msg); - } // End llvm namespace #endif diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index 509d2f3..21ac09c 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "SetTheory.h" +#include "Error.h" #include "Record.h" #include "llvm/Support/Format.h" diff --git a/utils/TableGen/TGLexer.cpp b/utils/TableGen/TGLexer.cpp index 572c36d..b4b90ff 100644 --- a/utils/TableGen/TGLexer.cpp +++ b/utils/TableGen/TGLexer.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "TGLexer.h" +#include "Error.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Config/config.h" @@ -35,7 +36,6 @@ SMLoc TGLexer::getLoc() const { return SMLoc::getFromPointer(TokStart); } - /// ReturnError - Set the error to the specified string at the specified /// location. This is defined to always return tgtok::Error. tgtok::TokKind TGLexer::ReturnError(const char *Loc, const Twine &Msg) { @@ -43,16 +43,6 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const Twine &Msg) { return tgtok::Error; } - -void TGLexer::PrintError(const char *Loc, const Twine &Msg) const { - SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error"); -} - -void TGLexer::PrintError(SMLoc Loc, const Twine &Msg) const { - SrcMgr.PrintMessage(Loc, Msg, "error"); -} - - int TGLexer::getNextChar() { char CurChar = *CurPtr++; switch (CurChar) { diff --git a/utils/TableGen/TGLexer.h b/utils/TableGen/TGLexer.h index c2a6453..84d328b 100644 --- a/utils/TableGen/TGLexer.h +++ b/utils/TableGen/TGLexer.h @@ -101,9 +101,6 @@ public: } SMLoc getLoc() const; - - void PrintError(const char *Loc, const Twine &Msg) const; - void PrintError(SMLoc Loc, const Twine &Msg) const; private: /// LexToken - Read the next token and return its code. diff --git a/utils/TableGen/TGParser.h b/utils/TableGen/TGParser.h index 419a99b..94a1c2b 100644 --- a/utils/TableGen/TGParser.h +++ b/utils/TableGen/TGParser.h @@ -15,6 +15,7 @@ #define TGPARSER_H #include "TGLexer.h" +#include "Error.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/SourceMgr.h" #include <map> @@ -60,7 +61,7 @@ public: bool ParseFile(); bool Error(SMLoc L, const Twine &Msg) const { - Lex.PrintError(L, Msg); + PrintError(L, Msg); return true; } bool TokError(const Twine &Msg) const { diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 4e4da36..39fe993 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -26,6 +26,7 @@ #include "DAGISelEmitter.h" #include "DisassemblerEmitter.h" #include "EDEmitter.h" +#include "Error.h" #include "FastISelEmitter.h" #include "InstrEnumEmitter.h" #include "InstrInfoEmitter.h" @@ -194,12 +195,6 @@ namespace { } -static SourceMgr SrcMgr; - -void llvm::PrintError(SMLoc ErrorLoc, const Twine &Msg) { - SrcMgr.PrintMessage(ErrorLoc, Msg, "error"); -} - int main(int argc, char **argv) { RecordKeeper Records; @@ -403,13 +398,11 @@ int main(int argc, char **argv) { return 0; } catch (const TGError &Error) { - errs() << argv[0] << ": error:\n"; - PrintError(Error.getLoc(), Error.getMessage()); - + PrintError(Error); } catch (const std::string &Error) { - errs() << argv[0] << ": " << Error << "\n"; + PrintError(Error); } catch (const char *Error) { - errs() << argv[0] << ": " << Error << "\n"; + PrintError(Error); } catch (...) { errs() << argv[0] << ": Unknown unexpected exception occurred.\n"; } |