[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 10 16:34:08 PST 2018


vsapsai added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2321
+          ArgI.getCoerceToType() ==
+              ConvertType(isPromoted ? Ty : Arg->getType()) &&
           ArgI.getDirectOffset() == 0) {
----------------
ahatanak wrote:
> Maybe a comment explaining why different types are passed depending on the value of isPromoted?
My reasoning was that for promoted arguments `emitArgumentDemotion` is responsible for bridging gaps between `Ty` and `Arg->getType()`, so it should be enough for `ArgI.getCoerceToType()` and `Ty` to match. But this explanation is woefully unsuitable for the comment.

After some more thinking I start doubting if some other s/Ty/Arg->getType()/ changes are entirely correct.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2469
         if (isPromoted)
           V = emitArgumentDemotion(*this, Arg, V);
         ArgVals.push_back(ParamValue::forDirect(V));
----------------
For example, here. If `V` is of type `Arg->getType()`, will `emitArgumentDemotion` do anything? Because there you have
```
if (value->getType() == varType) return value;
```

I'll keep digging and if meanwhile anybody has comments on this situation, I'll be glad to hear them.


https://reviews.llvm.org/D41311





More information about the cfe-commits mailing list