@@ -60,14 +60,14 @@ class TranslationUnit {
6060
6161 [[nodiscard]] auto globalScope () const -> Scope*;
6262
63- [[nodiscard]] auto fileName () const -> const std::string& {
64- return fileName_;
65- }
63+ [[nodiscard]] auto fileName () const -> const std::string&;
6664
6765 [[nodiscard]] auto preprocessor () const -> Preprocessor* {
6866 return preprocessor_.get ();
6967 }
7068
69+ void parse (ParserConfiguration config = {});
70+
7171 // set source and preprocess, deprecated.
7272 void setSource (std::string source, std::string fileName);
7373
@@ -77,27 +77,13 @@ class TranslationUnit {
7777
7878 void endPreprocessing ();
7979
80- [[nodiscard]] auto fatalErrors () const -> bool {
81- return diagnosticsClient_->fatalErrors ();
82- }
83-
84- void setFatalErrors (bool fatalErrors) {
85- diagnosticsClient_->setFatalErrors (fatalErrors);
86- }
87-
88- auto blockErrors (bool blockErrors = true ) -> bool {
89- return diagnosticsClient_->blockErrors (blockErrors);
90- }
80+ [[nodiscard]] auto fatalErrors () const -> bool;
81+ void setFatalErrors (bool fatalErrors);
9182
92- void error (SourceLocation loc, std::string message) const {
93- diagnosticsClient_->report (tokenAt (loc), Severity::Error,
94- std::move (message));
95- }
83+ auto blockErrors (bool blockErrors = true ) -> bool;
9684
97- void warning (SourceLocation loc, std::string message) const {
98- diagnosticsClient_->report (tokenAt (loc), Severity::Warning,
99- std::move (message));
100- }
85+ void error (SourceLocation loc, std::string message) const ;
86+ void warning (SourceLocation loc, std::string message) const ;
10187
10288 // tokens
10389 [[nodiscard]] inline auto tokenCount () const -> unsigned {
@@ -134,8 +120,6 @@ class TranslationUnit {
134120
135121 [[nodiscard]] auto literal (SourceLocation loc) const -> const Literal*;
136122
137- void parse (const ParserConfiguration& config = {});
138-
139123 [[nodiscard]] auto load (std::span<const std::uint8_t > data) -> bool;
140124
141125 [[nodiscard]] auto serialize (std::ostream& out) -> bool;
@@ -146,13 +130,13 @@ class TranslationUnit {
146130 private:
147131 std::unique_ptr<Control> control_;
148132 std::unique_ptr<Arena> arena_;
133+ std::unique_ptr<Preprocessor> preprocessor_;
149134 std::vector<Token> tokens_;
150135 std::string fileName_;
151136 UnitAST* ast_ = nullptr ;
152137 const char * yyptr = nullptr ;
153138 DiagnosticsClient* diagnosticsClient_ = nullptr ;
154139 NamespaceSymbol* globalNamespace_ = nullptr ;
155- std::unique_ptr<Preprocessor> preprocessor_;
156140};
157141
158142} // namespace cxx
0 commit comments