================
@@ -26,6 +26,19 @@ TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesInFile) {
EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO"))));
}
+static std::string constructMacroName(llvm::StringRef A, llvm::StringRef B) {
+ return (A + "_" + B).str();
+}
+
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_ConstructedMacroName) {
+ StringRef input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+ void Test() { MY_MACRO(4); }
+ )cc";
+ EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro(
+ constructMacroName("MY", "MACRO")))));
----------------
hokein wrote:
I think you need to abstract the `isExpandedFromMacro(...)` to a local variable
to reproduce the previous use-after-free issue:
```
auto matcher = isExpandedFromMacro(constructMacroName("MY", "MACRO"));
EXPECT_TRUE(matches(input, binaryOperator(matcher));
```
https://github.com/llvm/llvm-project/pull/169238
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits