[all-commits] [llvm/llvm-project] 970e1e: [clang] Fix crash with -funique-internal-linkage-n...

Ellis Hoag via All-commits all-commits at lists.llvm.org
Mon Oct 17 08:57:36 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 970e1ea01aa0dce4f606eee1610c92b8b838f303
      https://github.com/llvm/llvm-project/commit/970e1ea01aa0dce4f606eee1610c92b8b838f303
  Author: Ellis Hoag <ellis.sparky.hoag at gmail.com>
  Date:   2022-10-17 (Mon, 17 Oct 2022)

  Changed paths:
    M clang/lib/CodeGen/CGCall.cpp
    A clang/test/CodeGen/unique-internal-linkage-names.c

  Log Message:
  -----------
  [clang] Fix crash with -funique-internal-linkage-names

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

Reviewed By: tmsriram

Differential Revision: https://reviews.llvm.org/D135926




More information about the All-commits mailing list