aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2020-03-16 12:40:08 -0700
committerPeter Collingbourne <pcc@google.com>2020-03-18 14:53:58 -0700
commita705d28cf59ad89b2081c9cfdb9719dc8b0a49e7 (patch)
tree4132282342b41159e2cffacfc5c9db85c3eddfba
parent48309792d94c7b8d84e86193ee802232d108c9dd (diff)
downloadplatform_build_kati-a705d28cf59ad89b2081c9cfdb9719dc8b0a49e7.tar.gz
platform_build_kati-a705d28cf59ad89b2081c9cfdb9719dc8b0a49e7.tar.bz2
platform_build_kati-a705d28cf59ad89b2081c9cfdb9719dc8b0a49e7.zip
Display include stack when encountering an error.
-rw-r--r--eval.cc5
-rw-r--r--eval.h2
2 files changed, 7 insertions, 0 deletions
diff --git a/eval.cc b/eval.cc
index 8de8f41..aaad21f 100644
--- a/eval.cc
+++ b/eval.cc
@@ -444,6 +444,7 @@ void Evaluator::EvalInclude(const IncludeStmt* stmt) {
}
}
+ include_stack_.push_back(stmt->loc());
for (const string& fname : *files) {
if (!stmt->should_exist && g_flags.ignore_optional_include_pattern &&
Pattern(g_flags.ignore_optional_include_pattern).Match(fname)) {
@@ -451,6 +452,7 @@ void Evaluator::EvalInclude(const IncludeStmt* stmt) {
}
DoInclude(fname);
}
+ include_stack_.pop_back();
}
}
@@ -555,6 +557,9 @@ string Evaluator::GetShellAndFlag() {
}
void Evaluator::Error(const string& msg) {
+ for (auto& inc : include_stack_) {
+ fprintf(stderr, "In file included from %s:%d:\n", LOCF(inc));
+ }
ERROR_LOC(loc_, "%s", msg.c_str());
}
diff --git a/eval.h b/eval.h
index 0859cb1..e8a95ed 100644
--- a/eval.h
+++ b/eval.h
@@ -143,6 +143,8 @@ class Evaluator {
bool is_bootstrap_;
bool is_commandline_;
+ std::vector<Loc> include_stack_;
+
bool avoid_io_;
// This value tracks the nest level of make expressions. For
// example, $(YYY) in $(XXX $(YYY)) is evaluated with depth==2.