[llvm-commits] [PATCH] add GraphTraits for class User

Török Edwin edwintorok at gmail.com
Tue Apr 1 13:21:03 PDT 2008


Dan Gohman wrote:
> On Mar 31, 2008, at 10:51 AM, Török Edwin wrote:
>   
>> Hi,
>>
>> This patch adds GraphTraits for class User, allowing to use a
>> depth-first iterator to find out all values that depend on (use)  a
>> certain Value.
>> This can currently be done only by coding a recursive function.
>>
>> I tried to use forward declaration of GraphTraits/Inverse to avoid
>> including the header for it, but that doesn't work, because of  
>> Inverse.
>> Is it ok to include those headers in User.h? If not, where should I  
>> move
>> this GraphTraits code?
>>     
>
> Including those headers in User.h would be undesirable. Could you put
> this code in a new header file, similar to how
> llvm/Support/CFG.h contains the graph traits for BasicBlock objects?
>   

Ok, I named it Support/DataFlow.h.

Nick Lewycky wrote:
> Don't add this to User.h. Create Support/DataFlow.h? UseDef.h? Not sure.
>
> No tabs allowed.
>   

Ok, fixed.

> You have a lot of whitespace errors. Decide, is it "User *X" or "User* =
>
> X"? I suggest the former. Also, there should be a space after the "if" =
>
> keyword.
>   

I usually use "User *X" for variables and parameters, and "User*" for
function return types.
I don't have a good reason why, so using "User *X" consistently looks
like a good suggestion.
> Include a version that works on non-const User.
>   
Ok, I did that.

Thanks for the comments, I attached a new patch. Is the generic
description of this new file Ok?

Best regards,
--Edwin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: user_graphtraits2.patch
Type: text/x-diff
Size: 3025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080401/500af84b/attachment.patch>


More information about the llvm-commits mailing list