[PATCH] D95740: [ASTMatchers] Ignore parts of BindingDecls which are not spelled in source

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 05:27:29 PST 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2607
+    EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+    EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
----------------
steveire wrote:
> aaron.ballman wrote:
> > Can you help me to better understand the proposed change? I find this to be surprising behavior -- the thing the user wrote in the source are the binding declarations, the hidden thing they didn't write in the source was the decomposition declaration. e.g., the user introduced some names `f`, `s`, and `t` in the declaration so I would imagine that these *are* spelled in source. What I don't think is necessarily spelled in source is the decomposition declaration for the `int[3]` to bind to. So I was expecting this to be `EXPECT_TRUE` instead of `EXPECT_FALSE`.
> > Can you help me to better understand the proposed change? I find this to be surprising behavior -- the thing the user wrote in the source are the binding declarations, the hidden thing they didn't write in the source was the decomposition declaration. e.g., the user introduced some names `f`, `s`, and `t` in the declaration so I would imagine that these *are* spelled in source. What I don't think is necessarily spelled in source is the decomposition declaration for the `int[3]` to bind to. 
> 
> Indeed. The `bindingDecl` matches, but the `has(expr())` part does not, after this change: https://godbolt.org/z/Mqb9Mx
> 
> 
The test changes nicely clarify what's going on, thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95740/new/

https://reviews.llvm.org/D95740



More information about the cfe-commits mailing list