[torque] Enforce lint errors in the torque compiler

This CL adds a contextual variable that tracks lint errors and will
cause the Torque compiler to abort if there were any.

R=tebbi@chromium.org

Bug: v8:7793
Change-Id: Ia7c2b5b6c7cb12d489b12596afa84f933fc3f337
Reviewed-on: https://chromium-review.googlesource.com/1219388
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#55797}
This commit is contained in:
Simon Zünd 2018-09-11 16:31:34 +02:00 committed by Commit Bot
parent b9d71d9339
commit 77db602f4b
3 changed files with 20 additions and 0 deletions

View File

@ -26,6 +26,8 @@ int WrappedMain(int argc, const char** argv) {
CurrentSourceFile::Scope unknown_sourcefile_scope(
SourceFileMap::AddSource("<unknown>"));
CurrentAst::Scope ast_scope;
LintErrorStatus::Scope lint_error_status_scope;
for (int i = 1; i < argc; ++i) {
// Check for options
if (!strcmp("-o", argv[i])) {
@ -76,6 +78,9 @@ int WrappedMain(int argc, const char** argv) {
visitor.GenerateImplementation(output_directory, module.second.get());
}
}
if (LintErrorStatus::HasLintErrors()) std::abort();
return 0;
}

View File

@ -76,12 +76,15 @@ std::string CurrentPositionAsString() {
return PositionAsString(CurrentSourcePosition::Get());
}
DEFINE_CONTEXTUAL_VARIABLE(LintErrorStatus)
[[noreturn]] void ReportError(const std::string& error) {
std::cerr << CurrentPositionAsString() << ": Torque error: " << error << "\n";
std::abort();
}
void LintError(const std::string& error) {
LintErrorStatus::SetLintError();
std::cerr << CurrentPositionAsString() << ": Lint error: " << error << "\n";
}

View File

@ -10,6 +10,7 @@
#include <vector>
#include "src/base/functional.h"
#include "src/torque/contextual.h"
namespace v8 {
namespace internal {
@ -20,6 +21,17 @@ typedef std::vector<std::string> NameVector;
std::string StringLiteralUnquote(const std::string& s);
std::string StringLiteralQuote(const std::string& s);
class LintErrorStatus : public ContextualClass<LintErrorStatus> {
public:
LintErrorStatus() : has_lint_errors_(false) {}
static bool HasLintErrors() { return Get().has_lint_errors_; }
static void SetLintError() { Get().has_lint_errors_ = true; }
private:
bool has_lint_errors_;
};
[[noreturn]] void ReportError(const std::string& error);
void LintError(const std::string& error);