Cyber Risks · Trail of Bits Blog

Fast and accurate syntax searching for C and C++

Summary: A Trail of Bits intern prototyped an internal tool called Syntex that searches C and C++ source code by matching patterns against actual Clang ASTs rather than parsing text with custom parsers or regular expressions. Syntex builds a context-free grammar from the Clang AST, tokenizes queries into all possible interpretations, and parses them with a memoizing chart parser, with the post stating it has exceeded open-source alternatives such as Semgrep and weggli.

Key Takeaway: The post argues that existing pattern-searching tools parse without macro expansion and lack semantic understanding, so they cannot let a user confidently claim 'here are all the occurrences of this pattern' or 'this pattern never occurs' - a false-negative risk that matters when the search underpins vulnerability hunting in C and C++ codebases.

Read the original at Trail of Bits Blog ↗