This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix crash with -funique-internal-linkage-names
ClosedPublic

Authored by ellis on Oct 13 2022, 4:46 PM.

Details

Summary

Calling getFunctionLinkage(CalleeInfo.getCalleeDecl()) will crash when the declaration does not have a body, e.g., extern void foo();. Instead, we can use isExternallyVisible() to see if the delcaration has internal linkage.

I believe using !isExternallyVisible() is correct because the clang linkage must be InternalLinkage or UniqueExternalLinkage, both of which are "internal linkage" in llvm.
https://github.com/llvm/llvm-project/blob/9c26f51f5e178ac0fda98419e3a61d205d3b58b1/clang/include/clang/Basic/Linkage.h#L28-L40

Fixes https://github.com/llvm/llvm-project/issues/54139

Diff Detail

Event Timeline

ellis created this revision.Oct 13 2022, 4:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 4:46 PM
ellis published this revision for review.Oct 13 2022, 4:47 PM
ellis added reviewers: tmsriram, hoy, dblaikie.
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 4:47 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tmsriram accepted this revision.Oct 14 2022, 8:41 PM

LGTM, thanks for fixing this!

This revision is now accepted and ready to land.Oct 14 2022, 8:41 PM
This revision was automatically updated to reflect the committed changes.