[PATCH] D130055: Clang extensions yolo, woot & kaboom

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 18 18:15:11 PDT 2022


beanz created this revision.
beanz added reviewers: aaron.ballman, bogner, rnk, MaskRay, void.
Herald added a subscriber: StephenFan.
Herald added a reviewer: NoQ.
Herald added a project: All.
beanz requested review of this revision.
Herald added a project: clang.

Sometimes a default-initialized value isn't really properly
initialized. In most cases these are handled with assertions, but...
what if we could annotate our code to allow the compiler to detect
cases where "uninitialized" user-defined types get used.

Enter yolo, woot and kaboom!
(proper names pending)

The `yolo` attribute denotes a constructor as creating an
"uninitialized" variable.

The `woot` attribute appliest to member functions noting that they
initialize the base object.

The `kaboom` attribute applies to member functions noting that they
must have an initialized base object.

These additional annotations ensure that at least one `woot` function
must be called on an object initialized with a `yolo` constructor
before any `kaboom` functions can be called otherwise a diagnostic will
be issued via the standard -Wuninitialized diagnostics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130055

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Sema/uninit-attribute.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130055.445667.patch
Type: text/x-patch
Size: 5296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220719/96a2431f/attachment.bin>


More information about the cfe-commits mailing list