[PATCH] D34329: [GSoC] Clang AST diffing

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 20 08:41:40 PDT 2017


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





More information about the cfe-commits mailing list