aaron.ballman added inline comments.

================
Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:41
+static bool isAllowedSystemCall(const FunctionDecl *FD) {
+  if (!FD->getIdentifier())
+    return true;
----------------
balazske wrote:
> aaron.ballman wrote:
> > A function without an identifier is not a system call, so I would have 
> > expected this to return `false` based on the function name.
> I would think that if the function is an operation on a std object 
> (`std::vector`) it should be classified as system call, and these operations 
> (or many of them) look not asynchronous-safe.
Hmm, that's an interesting point I hadn't considered and I don't know what the 
correct answer is as it relates to this check. For instance, this code is bad, 
but not because of sig30-C:
```
std::vector<int> some_global_vector;
void sig_handler(int sig) {
  int &i = some_global_vector[0];
  ...
}
```
I doubt that `operator[]()` is actually making any system calls under the hood, 
so it's fine per sig30-c, but the code is still bad (it should fail sig31-c 
about not using shared objects from signals). On the flip side:
```
std::packaged_task<void(int)> some_task;
void sig_handler(int sig) {
  some_task(sig); // Who knows what this will execute when it calls operator()()
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to