================
@@ -80,6 +80,20 @@ void MacroUsageCheck::warnMacro(const MacroDirective *MD, 
StringRef MacroName) {
   const MacroInfo *Info = MD->getMacroInfo();
   StringRef Message;
 
+  for (const auto &T : MD->getMacroInfo()->tokens()) {
+    if (T.is(tok::hash)) {
+      return;
+    }
+    if (T.is(tok::identifier)) {
+      StringRef IdentName = T.getIdentifierInfo()->getName();
+      if (IdentName == "__FILE__") {
+        return;
+      } else if (IdentName == "__LINE__") {
+        return;
+      }
+    }
+  }
+
----------------
PiotrZSL wrote:

Won't work for:
```
 #define MyLineAndFile __FILE__, __LINE__
#define logSomething(x) log(MyLineAndFile, x)
```

For me MacroExpands woud need to be used. And even for this scenario, would be 
good to add some configuration option regex and match to that.

https://github.com/llvm/llvm-project/pull/80797
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to