[llvm-commits] [llvm] r83324 - /llvm/trunk/lib/Analysis/MallocHelper.cpp

Török Edwin edwintorok at gmail.com
Tue Oct 6 00:16:30 PDT 2009


On 2009-10-06 09:53, Chris Lattner wrote:
>
> On Oct 5, 2009, at 11:49 PM, Duncan Sands wrote:
>
>> Hi Torok,
>>
>>> +  // Check malloc prototype.
>>> +  // FIXME: this will be obsolete when nobuiltin attribute will exist.
>>
>> why would it be obsolete then?  If LLVM sees "malloc" with a funky
>> prototype it will always need to bail out, no?
>
> Why would it in this case?  Though it doesn't make a lot of sense, it
> wouldn't cause the program to crash, and the code would have undefined
> behavior.

Once the LLVM optimizers/backends can emit warnings with line numbers, I
think we should emit a warning if we see something obviously wrong being
done,
like using malloc with a wrong proto without using
-ffreestanding/nobuiltins, or calling a function with an obviously wrong
calling convention, etc.
Now that we have debug info when optimizing too, I think this is doable,
maybe those warnings should be default off, and have a hook, so clang
can print it as a diagnostic, etc.

In fact I think we should emit a warning when we see a definition for
malloc/some other special function without the nobuiltin attribute, or
with a mismatching proto.

What do you think?


Best regards,
--Edwin




More information about the llvm-commits mailing list