]> granicus.if.org Git - clang/commit
[WebAssembly] Add an import_field function attribute
authorDan Gohman <dan433584@gmail.com>
Fri, 1 Feb 2019 22:25:23 +0000 (22:25 +0000)
committerDan Gohman <dan433584@gmail.com>
Fri, 1 Feb 2019 22:25:23 +0000 (22:25 +0000)
commitebf804407846b49f29bd5eff91a955aa2cc9743b
tree42937ac0ca88693fe89c948661207ea92d72cbb2
parent207c6e6243d3cac318287382d2ce7d2de071800d
[WebAssembly] Add an import_field function attribute

This is similar to import_module, but sets the import field name
instead.

By default, the import field name is the same as the C/asm/.o symbol
name. However, there are situations where it's useful to have it be
different. For example, suppose I have a wasm API with a module named
"pwsix" and a field named "read". There's no risk of namespace
collisions with user code at the wasm level because the generic name
"read" is qualified by the module name "pwsix". However in the C/asm/.o
namespaces, the module name is not used, so if I have a global function
named "read", it is intruding on the user's namespace.

With the import_field module, I can declare my function (in libc) to be
"__read", and then set the wasm import module to be "pwsix" and the wasm
import field to be "read". So at the C/asm/.o levels, my symbol is
outside the user namespace.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352930 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
lib/CodeGen/TargetInfo.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGen/wasm-import-name.c [new file with mode: 0644]
test/Misc/pragma-attribute-supported-attributes-list.test