* 直接从源代码中,找出想要的
查找判断 AST 抽象语法树中 if 节点相关的, clang 的代码
➜ llvm-projectX git:(main) ✗ git grep kw_if
kw, key word
打印出,不相关的
clang/lib/Format/FormatToken.h: return is(tok::kw_if) || endsSequence(tok::kw_constexpr, tok::kw_if) ||
clang/lib/Format/FormatToken.h: (endsSequence(tok::identifier, tok::kw_if) && AllowConstexprMacro);
clang/lib/Format/FormatToken.h: case tok::kw_if:
clang/lib/Format/FormatToken.h: case tok::kw_if:
还有,相关的
clang/lib/Parse/ParseExpr.cpp: K == tok::kw_if || K == tok::kw_else ||
clang/lib/Parse/ParseObjc.cpp: case tok::kw_if:
clang/lib/Parse/ParseStmt.cpp: case tok::kw_if: // C99 6.8.4.1: if-statement
clang/lib/Parse/ParseStmt.cpp: assert(Tok.is(tok::kw_if) && "Not an if stmt!");
需要的是, inspect the AST nodes
这是 the job of semantic analysis
semantic analysis, 语义分析
定位到这里
clang/lib/Parse/ParseStmt.cpp: assert(Tok.is(tok::kw_if) && "Not an if stmt!");
/// ParseIfStatement
/// if-statement: [C99 6.8.4.1]
/// 'if' '(' expression ')' statement
/// 'if' '(' expression ')' statement 'else' statement
/// [C++] 'if' '(' condition ')' statement
/// [C++] 'if' '('