[PATCH] D97251: [llvm] Add assertions for the smart pointers with the possibility to be null in ClangAttrEmitter

Ella Ma via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 21:07:43 PST 2021


OikawaKirie created this revision.
OikawaKirie added reviewers: dexonsmith, aaron.ballman, pcc.
OikawaKirie added a project: clang.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

Split from D91844 <https://reviews.llvm.org/D91844>.

The return value of createArgument in file clang/utils/TableGen/ClangAttrEmitter.cpp. Although there are a lot of checks in the function, nullptr is still possible to be returned.
In this patch, I added an assertion to confirm that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97251

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===================================================================
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1361,6 +1361,8 @@
     }
   }
 
+  assert(Ptr && "Cannot create argument.");
+
   if (Ptr && Arg.getValueAsBit("Optional"))
     Ptr->setOptional(true);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97251.325661.patch
Type: text/x-patch
Size: 368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210223/a9139c12/attachment.bin>


More information about the cfe-commits mailing list