dim added inline comments.

================
Comment at: clang/include/clang/AST/DeclContextInternals.h:102
     // at getLookupResult.
-    assert(*(NamedDecl **)&Data == ND &&
+    assert(Data.getAddrOfPtr1() && *Data.getAddrOfPtr1() == ND &&
            "PointerUnion mangles the NamedDecl pointer!");
----------------
Hm, I don't have much experience with the `PointerUnion` class, but from a 
cursory look at `llvm/include/llvm/ADT/PointerUnion.h`, I would rather say that 
using `dyn_cast` here would be more appropriate?  E.g. that definition 
literally says:

```
  /// Returns the current pointer if it is of the specified pointer type,
  /// otherwises returns null.
```

So something like:

```
  assert(Data.dyn_cast<NameDecl> == ND &&
    "PointerUnion mangles the NamedDecl pointer!");
```

or even using the existing `getAsDecl` member function, which does exactly the 
same:

```
  assert(Data.getAsDecl() == ND &&
    "PointerUnion mangles the NamedDecl pointer!");
```

Or is this particular check about the type being *only* the base class 
`NamedDecl`, and not any derived class?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71827/new/

https://reviews.llvm.org/D71827



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

Reply via email to