Commit 77db602f authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[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/1219388Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#55797}
parent b9d71d93
......@@ -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;
}
......
......@@ -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";
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment