[PATCH] D129097: [clang][dataflow] Handle null pointers of type std::nullptr_t

Eric Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 09:57:01 PDT 2022


li.zhe.hua marked an inline comment as done.
li.zhe.hua added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:96
   ///
   ///  `Type` must not be null.
   StorageLocation &getStableStorageLocation(QualType Type);
----------------
sgatev wrote:
> This is inconsistent with the change introduced by this patch.
Ah, you're correct. I can mail a fix out later today.


================
Comment at: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp:27
 DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
-  assert(!Type.isNull());
-  if (Type->isStructureOrClassType() || Type->isUnionType()) {
+  if (!Type.isNull() &&
+      (Type->isStructureOrClassType() || Type->isUnionType())) {
----------------
sgatev wrote:
> What does that mean? We are analyzing an incomplete translation unit? Why would the type ever be null here?
See the motivating test case:

```
// Alternatively, use `std::nullptr_t` instead of `my_nullptr_t`.
using my_nullptr_t = decltype(nullptr);
my_nullptr_t Null = 0;
```

This triggers `getOrCreateNullPointerValue` to be called with a null pointee type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129097



More information about the cfe-commits mailing list