From 010963ce431db2648374368dfc886aa8482494a9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 9 May 2019 14:52:06 -0400 Subject: stage1: make some asserts print source location --- src/analyze.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index aa510003b8..c441676e77 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -7230,3 +7230,16 @@ ZigLLVMDIType *get_llvm_di_type(CodeGen *g, ZigType *type) { assertNoError(type_resolve(g, type, ResolveStatusLLVMFull)); return type->llvm_di_type; } + +void src_assert(bool ok, AstNode *source_node) { + if (ok) return; + if (source_node == nullptr) { + fprintf(stderr, "when analyzing (unknown source location): "); + } else { + fprintf(stderr, "when analyzing %s:%u:%u: ", + buf_ptr(source_node->owner->data.structure.root_struct->path), + (unsigned)source_node->line + 1, (unsigned)source_node->column + 1); + } + const char *msg = "assertion failed"; + stage2_panic(msg, strlen(msg)); +} -- cgit v1.2.3