Coverage Report

Created: 2025-12-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hermes/lib/AST/SemValidate.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#include "hermes/AST/SemValidate.h"
9
#include "hermes/AST/ES6Class.h"
10
11
#include "hermes/Support/PerfSection.h"
12
13
#include "SemanticValidator.h"
14
15
namespace hermes {
16
namespace sem {
17
18
154
bool validateAST(Context &astContext, SemContext &semCtx, Node *root) {
19
154
  PerfSection validation("Validating JavaScript function AST");
20
154
  if (astContext.getCodeGenerationSettings().enableBlockScoping) {
21
0
    canonicalizeForBlockScoping(astContext, root);
22
0
  }
23
154
  if (astContext.getConvertES6Classes()) {
24
    // Convert ES6 classes to functions
25
0
    transformES6Classes(astContext, root);
26
0
  }
27
28
  // Validate the entire AST.
29
154
  SemanticValidator validator{astContext, semCtx, true};
30
154
  return validator.doIt(root);
31
154
}
32
33
0
bool validateASTForParser(Context &astContext, SemContext &semCtx, Node *root) {
34
0
  if (astContext.getCodeGenerationSettings().enableBlockScoping) {
35
0
    canonicalizeForBlockScoping(astContext, root);
36
0
  }
37
0
  SemanticValidator validator{astContext, semCtx, false};
38
0
  return validator.doIt(root);
39
0
}
40
41
bool validateFunctionAST(
42
    Context &astContext,
43
    SemContext &semCtx,
44
    Node *function,
45
0
    bool strict) {
46
0
  PerfSection validation("Validating JavaScript function AST: Deep");
47
0
  if (astContext.getCodeGenerationSettings().enableBlockScoping) {
48
0
    canonicalizeForBlockScoping(astContext, function);
49
0
  }
50
0
  SemanticValidator validator{astContext, semCtx, true};
51
0
  return validator.doFunction(function, strict);
52
0
}
53
54
} // namespace sem
55
} // namespace hermes