================
@@ -22,6 +24,22 @@ static EntityLinkageType getLinkageForDecl(const Decl *D) {
if (!ND)
return EntityLinkageType::None;
+ // Parameters have no linkage in C++, but SSAF needs them to inherit
+ // the external linkage from their parent functions.
+ // Here is why:
+ // SSAF treats parameters as entities and may not always associate them
back
+ // to their parent functions. Therefore, it needs to identify parameters of
+ // functions with external linkage across different TUs. Treating them as
+ // having no linkage (as in C++) causes the same parameter in different TUs
+ // to be assigned different EntityIDs. As a result, the behavior of the
+ // parameter across multiple TUs cannot be correlated.
+ if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
+ if (const FunctionDecl *FD = llvm::dyn_cast_or_null<FunctionDecl>(
----------------
steakhal wrote:
Let's not repeat the type, and also admit that a ParamVarDecl always lives
inside some FunctionDecl - thus we don't need a `dyn_cast_or_null` and we can
just use `dyn_cast`.
```suggestion
if (const auto *FD = llvm::dyn_cast<FunctionDecl>(
```
https://github.com/llvm/llvm-project/pull/201946
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits