Clang AST Matcher的“ AND”和“ OR”

ign*_*rer 3 clang clang-static-analyzer

我是Clang的AST Matcher API的初学者。我有一个天真的问题,可以匹配某事。某物 ?喜欢:

functionDecl(hasName("a") or hasName("b"))
Run Code Online (Sandbox Code Playgroud)

还是我们必须使用“ addMatcher ”添加更多匹配器以获得相同的结果?

提前致谢!

Som*_*Tim 7

有几个变窄的匹配器构成其他匹配器的逻辑组合:anyOf类似于“或”,allOf可以实现“与”,并且unless类似于“非”。您的示例可能看起来像

functionDecl(
  anyOf(
    hasName("a"),
    hasName("b") ))
Run Code Online (Sandbox Code Playgroud)