[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 05:39:15 PST 2020


steakhal added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp:33-50
+void SignalInMultithreadedProgramCheck::registerMatchers(MatchFinder *Finder) {
+  auto signalCall =
+      callExpr(
+          ignoringImpCasts(hasDescendant(declRefExpr(hasDeclaration(
+              functionDecl(allOf(hasName("signal"), parameterCountIs(2),
+                                 hasParameter(0, hasType(isInteger())))))))))
+          .bind("signal");
----------------
I apologize for interrupting the review.
Should we use `hasDescendant` for matching like everything in translation unit?

Wouldn't it be more performant to collect all the `signal` calls in a set and set a bool variable if a `ThreadList` function seen? 
At the end of the analysis of the translation unit, emit warnings for each recorded `signal` call if the variable was set //(aka. we are in multithreaded environment)//.

Treat this comment rather a question since I'm not really familiar with `clang-tidy`.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229





More information about the cfe-commits mailing list