[cfe-dev] c++14 vs c++17 different ast for lambda?

Evgeniy Dushistov via cfe-dev cfe-dev at lists.llvm.org
Thu May 6 04:42:14 PDT 2021


On Wed, May 05, 2021 at 08:18:36PM +0100, Stephen Kelly wrote:
> 
> I'm not sure what "the tool" is,

clazy https://invent.kde.org/sdk/clazy
I am not author of it, just user who found out that it doesn't produce
some warnings in case of "-std=c++17".

It tries match LambdaExpr as argument of function call via traverse of
clang::Stmt childs, but doesn't expect it in the "parent stmt":
https://invent.kde.org/sdk/clazy/-/blob/0dbfa9f3a715924d8fd315897228bfe415afb92b/src/checks/level1/connect-3arg-lambda.cpp#L76
https://invent.kde.org/sdk/clazy/-/blob/0dbfa9f3a715924d8fd315897228bfe415afb92b/src/HierarchyUtils.h#L112

> but there are multiple places where clang
> generates a different AST based on the C++ dialect, including simple
> implicit constructions. See
> 
>  https://clang.llvm.org/docs/LibASTMatchersReference.html#traverse-mode
> 
> and
> 
>  https://steveire.wordpress.com/2021/02/14/ast-matchmaking-made-easy/
> 
> If you are not using AST Matchers, you might find it useful to call
> `Expr::IgnoreUnlessSpelledInSource()`.
> 
 
What about MaterializeTemporaryExpr? In other "checks" it is used,
to catch when implicitly shared object used in expression where
it can be "deep copied" by accident.

-- 
/Evgeniy


More information about the cfe-dev mailing list