Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Infer gsl::Pointer for vector<bool>::reference #47

Open
mgehre opened this issue Aug 21, 2019 · 2 comments
Open

Infer gsl::Pointer for vector<bool>::reference #47

mgehre opened this issue Aug 21, 2019 · 2 comments

Comments

@mgehre
Copy link
Owner

mgehre commented Aug 21, 2019

Move the code from

if (IsVectorBoolReference(Decl))
into Sema where the other std:: types are infered.

@mgehre
Copy link
Owner Author

mgehre commented Aug 21, 2019

fyi @Xazax-hun

@Xazax-hun
Copy link
Collaborator

Xazax-hun commented Aug 27, 2019

I did a quick look into this. Using the following diff:

diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index acf06cc9cae..749ee891071 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -133,6 +133,14 @@ void Sema::inferGslPointerAttribute(NamedDecl *ND,
       Containers.count(Parent->getName()))
     addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context,
                                                           UnderlyingRecord);
+  // The vector<bool>::reference is a pointer.
+  // TODO: The code below should work for most cases, but pre C++11 it
+  // it possible to have a non-record reference type for non-bool vectors
+  // that have custom allocators. Check if the template argument is bool!
+  if (Parent->isInStdNamespace() && ND->getName() == "reference" &&
+      Parent->getName() == "vector")
+    addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context,
+                                                          UnderlyingRecord);
 }
 
 void Sema::inferGslPointerAttribute(TypedefNameDecl *TD) {

I was able to make the proxy class annotated. However, in the meantime, I realized the std::vector<bool> specialization is not annotated as Owner.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants