[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

Dhruv Chawla via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 10 20:51:40 PST 2023


0xdc03 added a comment.

Note that as it stands currently, this patch cannot be committed because the test `clang/test/SemaCXX/externc-ifunc-resolver.cpp` fails to run. The contents of the test are as follows:

  // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-linux-gnu -verify %s
  
  extern "C" {
  __attribute__((used)) static void *resolve_foo() { return 0; }
  namespace NS {
  __attribute__((used)) static void *resolve_foo() { return 0; }
  } // namespace NS
  
  // FIXME: This diagnostic is pretty confusing, the issue is that the existence
  // of the two functions suppresses the 'alias' creation, and thus the ifunc
  // resolution via the alias as well. In the future we should probably find
  // some way to improve this diagnostic (likely by diagnosing when we decide
  // this case suppresses alias creation).
  __attribute__((ifunc("resolve_foo"))) void foo(); // expected-error{{ifunc must point to a defined function}}
  }

The error that I get is as follows:

  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + /mnt/entschuldigung/LLVM/llvm-main/build-release/bin/clang -cc1 -internal-isystem /mnt/entschuldigung/LLVM/llvm-main/build-release/lib/clang/17/include -nostdsysteminc -emit-llvm-only -triple x86_64-linux-gnu -verify /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp
  error: 'note' diagnostics seen but not expected:
    File /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp Line 14: 'resolve_foo' exists as a mangled name, did you mean to use '_ZL11resolve_foov'?
    File /mnt/entschuldigung/LLVM/llvm-main/clang/test/SemaCXX/externc-ifunc-resolver.cpp Line 14: 'resolve_foo' exists as a mangled name, did you mean to use '_ZN2NSL11resolve_fooEv'?
  2 errors generated.
  
  --

which confuses me because an `extern "C"` block is not supposed to mangle any names, right? Appreciate any inputs on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803



More information about the cfe-commits mailing list