[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

Matthias Gehre via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 30 14:24:24 PDT 2019


mgehre added inline comments.


================
Comment at: clang/include/clang/Sema/Sema.h:6097
+
+  /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
+  void addDefaultGslPointerAttribute(TypedefNameDecl *TD);
----------------
gribozavr wrote:
> It seems like this function does not add gsl::Owner.
Fixed comment


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:1689
   AddPushedVisibilityAttribute(NewClass);
+  addDefaultGslOwnerPointerAttribute(NewClass);
 
----------------
gribozavr wrote:
> It shouldn't be necessary to perform inference here, instead, the attributes should be instantiated, see `instantiateDependentAlignedAttr` in SemaTemplateInstantiateDecl.cpp for an example.
>From what I understand, here the attribute is put on the `ClassTemplateDecl`. Without this, there would be no attribute to instantiate from?
The instantiation of OwnerAttr/PointerAttr is auto-generated into instantiateTemplateAttribute() in `build/tools/clang/include/clang/Sema/AttrTemplateInstantiate.inc`.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:702
   SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef);
+  SemaRef.addDefaultGslPointerAttribute(Typedef);
 
----------------
gribozavr wrote:
> Ditto, should not be necessary to perform inference here.
I'll move this to already act on the typedef in the ClassTemplateDecl (instead of the instantiation here).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448





More information about the cfe-commits mailing list