[PATCH] D18727: Add support for attribute in the C API
Amaury SECHET via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 3 14:37:20 PDT 2016
deadalnix added inline comments.
================
Comment at: tools/llvm-c-test/echo.cpp:771-777
@@ -761,1 +770,9 @@
+
+ // Copy attributes
+ for (unsigned k = 0, e = LLVMGetEndAttrKind(); k < e; ++k) {
+ if (LLVMHasFunctionAttr(Cur, k))
+ LLVMAddFunctionAttr(F, k);
+ if (LLVMHasReturnAttr(Cur, k))
+ LLVMAddReturnAttr(F, k);
+ }
----------------
I went for the alternative first, namely mapping the attribute set. It was much bigger/more complex, and did not provide any significant advantage in real world use case.
When interacting with attribute, I usually want to check if X has attribute Y, or set attribute Y on X. Rarely do I want to iterate over all attributes (in fact, this test is the only time I ended up doing this).
This test does a lot of wasteful things on purpose in order to grill the C API. I think we are fine here.
http://reviews.llvm.org/D18727
More information about the llvm-commits
mailing list