Make sure a variable is initialized before use to clean up a warning from
[oota-llvm.git] / include / llvm / Assembly / Parser.h
1 //===-- llvm/Assembly/Parser.h - Parser for VM assembly files ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  These classes are implemented by the lib/AsmParser library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ASSEMBLY_PARSER_H
15 #define LLVM_ASSEMBLY_PARSER_H
16
17 #include <string>
18
19 namespace llvm {
20
21 class Module;
22 class ParseException;
23
24
25 // The useful interface defined by this file... Parse an ascii file, and return
26 // the internal representation in a nice slice'n'dice'able representation.  Note
27 // that this does not verify that the generated LLVM is valid, so you should run
28 // the verifier after parsing the file to check that it's ok.
29 //
30 Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
31 Module *ParseAssemblyString(const char * AsmString, Module * M);// throw (ParseException)
32
33 //===------------------------------------------------------------------------===
34 //                              Helper Classes
35 //===------------------------------------------------------------------------===
36
37 // ParseException - For when an exceptional event is generated by the parser.
38 // This class lets you print out the exception message
39 //
40 class ParseException {
41 public:
42   ParseException(const std::string &filename, const std::string &message,
43                  int LineNo = -1, int ColNo = -1);
44
45   ParseException(const ParseException &E);
46
47   // getMessage - Return the message passed in at construction time plus extra
48   // information extracted from the options used to parse with...
49   //
50   const std::string getMessage() const;
51
52   inline const std::string &getRawMessage() const {   // Just the raw message...
53     return Message;
54   }
55
56   inline const std::string &getFilename() const {
57     return Filename;
58   }
59
60   // getErrorLocation - Return the line and column number of the error in the
61   // input source file.  The source filename can be derived from the
62   // ParserOptions in effect.  If positional information is not applicable,
63   // these will return a value of -1.
64   //
65   inline const void getErrorLocation(int &Line, int &Column) const {
66     Line = LineNo; Column = ColumnNo;
67   }
68
69 private :
70   std::string Filename;
71   std::string Message;
72   int LineNo, ColumnNo;                               // -1 if not relevant
73
74   ParseException &operator=(const ParseException &E); // objects by reference
75 };
76
77 } // End llvm namespace
78
79 #endif