Attribute C-interface since LLVM-4.0

I try to guess how the new Attribute C-interface since LLVM-3.9 works, but it seems I have not guessed correctly so far. See attached example. First file uses the API before LLVM-3.9 and second file uses the API starting with LLVM-3.9. Essentially I replaced

     (call_exp, LLVMAttributeFunctionIndex, LLVMReadNoneAttribute);


   unsigned attrKind = LLVMGetEnumAttributeKindForName("readnone", 8);
   LLVMContextRef context = LLVMGetGlobalContext();
   LLVMAttributeRef attr = LLVMCreateEnumAttribute (context, attrKind, 0);
   LLVMAddAttributeAtIndex(call_exp, LLVMAttributeFunctionIndex, attr);

But in the generated Bitcode file no "readnone" attribute shows up.

callattribute.c (1.92 KB)

callattribute.c (2.08 KB)

The solution is: It must be LLVMAddCallSiteAttribute instead of LLVMAddAttributeAtIndex.