[PATCH] D89212: PR47663: Warn if an entity becomes weak after its first use.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 17:40:14 PDT 2020


rsmith marked an inline comment as done.
rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:6435-6436
+    Attr *WeakA = nullptr;
+    for (Attr *A : VD->getAttrs()) {
+      if (!isa<WeakAttr, WeakRefAttr, WeakImportAttr, AvailabilityAttr>(A))
+        continue;
----------------
aaron.ballman wrote:
> Ah, it's too bad that `Decl::specific_attrs()` doesn't accept a pack of attributes...
I took a brief look at fixing that, but it's not a completely natural extension because we would want to use a different `value_type` for the iterator if there's more than one kind under consideration. Probably not worth it for only one user.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:18288
 
-  if (PrevDecl) {
-    PrevDecl->addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc, AttributeCommonInfo::AS_Pragma));
+  if (NamedDecl *PrevDecl =
+          LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName)) {
----------------
aaron.ballman wrote:
> Same request for `const` here as above.
Can't make this `const`; this function modifies the declaration by adding an attribute :) But I can make `VD` below const.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89212



More information about the cfe-commits mailing list