[llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct

Chris Lattner clattner at apple.com
Fri Jan 15 10:20:01 PST 2010


On Jan 15, 2010, at 9:51 AM, Devang Patel wrote:

>> +++ llvm/trunk/include/llvm/IntrinsicInst.h Thu Jan 14 21:37:48 2010
>> @@ -25,6 +25,7 @@
>>  #define LLVM_INTRINSICINST_H
>>
>>  #include "llvm/Constants.h"
>> +#include "llvm/Metadata.h"
>>  #include "llvm/Function.h"
>>  #include "llvm/Instructions.h"
>>  #include "llvm/Intrinsics.h"
>> @@ -82,7 +83,12 @@
>>   ///
>>   class DbgDeclareInst : public DbgInfoIntrinsic {
>>   public:
>> -    Value *getAddress()  const { return getOperand(1); }
>> +    Value *getAddress() const {
>> +      if (MDNode* MD = dyn_cast<MDNode>(getOperand(1)))
>> +       return MD->getOperand(0);
>> +      else
>> +       return NULL;
>> +    }
>
> If getOperand(1) is either MDNode or NULL. Pl. add an assert to check
> if it is anything else.

Right, please use cast_or_null instead of dyn_cast.

>
> If you move this def. in .cpp then you can avoid including  
> Metadata.h here.


Agreed, please do.

-Chris



More information about the llvm-commits mailing list