[PATCH] D84604: Thread safety analysis: Consider global variables in scope

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 25 06:22:28 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM



================
Comment at: clang/lib/Analysis/ThreadSafety.cpp:1275
+    const ValueDecl *VD = LP->clangDecl();
+    return VD->isDefinedOutsideFunctionOrMethod();
+  }
----------------
Hmm, I've not seen that function used a whole lot before, but looking at the implementation of it, I think it does what we need it to do here. FWIW, I was expecting something more like this:
```
if (const DeclContext *DC = VD->getLexicalDeclContext())
  return !DC->getRedeclContext()->isFunctionOrMethod();
```
But I'm not certain if this would ever give a different answer from your approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84604



More information about the cfe-commits mailing list