[PATCH] D118996: [clang-tidy] Support C++14 in bugprone-signal-handler.

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 03:55:01 PDT 2022

whisperity accepted this revision.
whisperity added a comment.

Alright, I think we should have this in and let C++17 things to be future work. Please see the inline comment, but otherwise this should be good enough. Can always improve in a future version. 😉

LLVM 15 has branched off, so this should be rebased for the last time against the current main branch, just to ensure everything is good.

Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:284-298
+bool isCXXOnlyStmt(const Stmt *S) {
+  StringRef Name = S->getStmtClassName();
+  if (Name.startswith("CXX"))
+    return true;
+  // Check for all other class names in ExprCXX.h that have no 'CXX' prefix.
+  return isa<ArrayTypeTraitExpr, BuiltinBitCastExpr, CUDAKernelCallExpr,
+             CoawaitExpr, CoreturnStmt, CoroutineBodyStmt, CoroutineSuspendExpr,
I have an overarching solution idea for this, @balazske, which requires a separate patch independently of this. (I believe this will not be a //hard// thing to implement, just tedious, because of all the classes that need to be changed.)

Let's consider adding a new member function to `Decl`, `Stmt`, `Type`, etc. instances. While `bool isCXX() const` seems tempting, I believe it should be something like `bool isAvailableIn(const LangOptions&) const`, which returns whether a particular node (representing a language feature) //is available in// a particular //language option set//. And this way, we could query if a node is available in C++ (whichever version) and not in C, in which case the check can deduce that it is "C++-only".

This way, the future maintenance burden will be completely lifted from the check, and the AST library/API gets a useful generic feature that we can start using elsewhere, too!


So, e.g., `LambdaExpr` will have:

bool LambdaExpr::isAvailableIn(const LangOptions& LO) const
  return LO.CPlusPlus11;

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list