================
@@ -1341,6 +1341,14 @@ checkExprLifetimeImpl(Sema &SemaRef, const 
InitializedEntity *InitEntity,
       }
 
       if (IsGslPtrValueFromGslTempOwner && DiagLoc.isValid()) {
+
+        if (SemaRef.getLangOpts().CPlusPlus23) {
----------------
hokein wrote:

the analysis is done here, and we filter out the result. I think we can filter 
out this case before (in `checkExprLifetimeImpl`) running the analysis to save 
some cost. 

Can you add a testcase (for the `lifetimebound` attr)? Make sure we don't warn 
on it

```
using size_t = decltype(sizeof(void *));

namespace my_ns {
template <typename T> struct vector {
  T &operator[](size_t I) [[clang::lifetimebound]];
};

struct string {
  const char *begin();
  const char *end();
};

} // namespace std

my_ns::vector<my_ns::string> getData();

void foo() {

  for (auto c : getData()[0]) {
    (void)c;
  }
}
```

https://github.com/llvm/llvm-project/pull/145164
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to