Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to clear ErrorReporter; helps unit tests that need a clean error state #448

Merged
merged 2 commits into from
Apr 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ class ErrorReporter final {
return warningCount;
}

// Resets this ErrorReporter to its initial state.
void clear() {
errorCount = 0;
warningCount = 0;
}

// Special error functions to be called from the parser only.
// In the parser the IR objects don't yet have position information.
// Use printf-format style arguments.
Expand Down Expand Up @@ -469,4 +475,8 @@ inline void warning(const char* format, T... args) {
ErrorReporter::instance.warning(format, args...);
}

inline void clearErrorReporter() {
ErrorReporter::instance.clear();
}

#endif /* P4C_LIB_ERROR_H_ */