arphaman added inline comments.

================
Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:303
+/// Identifies a node in this subtree by its postorder offset.
+using SNodeId = int;
+
----------------
johannes wrote:
> arphaman wrote:
> > What's the difference between `SNodeId` and `NodeId`?
> NodeId is the preorder offset inside the root tree, starting at 0.
> SNodeId is the postorder offset within a subtree, starting at 1.
> Not sure if this irregularity can be improved upon easily, but I guess I can 
> mention it in the comments. 
Ok. It's fine to have two different types for them, but to avoid confusions I 
think that the code should be constructed in such a way that prohibits passing 
in `NodeId` to a function that expects `SNodeId` and vice-versa. You can wrap 
SNodeId in a typedef with an explicit constructor to achieve that goal, e.g.:

```
struct SNodeId {
  int Id;

  explicit SNodeId(int Id) : Id(Id) { };
}; 
```


https://reviews.llvm.org/D34329



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to