mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 22:02:37 +01:00
Implement static analysis of unformed usage on local variables. (#1831)
- An introprocedural forward analysis that checks the may-be-formed states on local variables. - Returns compilation error on usage of must-be-unformed variables. - Implemented as a pass of `ASTNode` traversal. - Currently supports detection of: function parameter, return expression and rhs of assign.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "explorer/interpreter/interpreter.h"
|
||||
#include "explorer/interpreter/resolve_control_flow.h"
|
||||
#include "explorer/interpreter/resolve_names.h"
|
||||
#include "explorer/interpreter/resolve_unformed.h"
|
||||
#include "explorer/interpreter/type_checker.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
@@ -45,8 +46,11 @@ auto ExecProgram(Nonnull<Arena*> arena, AST ast,
|
||||
}
|
||||
CARBON_RETURN_IF_ERROR(TypeChecker(arena, trace_stream).TypeCheck(ast));
|
||||
if (trace_stream) {
|
||||
**trace_stream << "\n";
|
||||
**trace_stream << "********** type checking complete **********\n";
|
||||
**trace_stream << "********** resolving unformed variables **********\n";
|
||||
}
|
||||
CARBON_RETURN_IF_ERROR(ResolveUnformed(ast));
|
||||
if (trace_stream) {
|
||||
**trace_stream << "********** printing declarations **********\n";
|
||||
for (const auto decl : ast.declarations) {
|
||||
**trace_stream << *decl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user