================
@@ -1839,6 +1839,70 @@ static void handleRestrictAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
                  RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx));
 }
 
+bool Sema::CheckSpanLikeType(const AttributeCommonInfo &CI,
+                             const QualType &Ty) {
+  // Note that there may also be numerous cases of pointer + integer /
+  // pointer + pointer / integer + pointer structures not actually exhibiting
+  // a span-like semantics, so sometimes these heuristics expectedly
+  // lead to false positive results.
+  auto emitWarning = [this, &CI](unsigned NoteDiagID) {
+    Diag(CI.getLoc(), diag::warn_attribute_return_span_only) << CI;
+    return Diag(CI.getLoc(), NoteDiagID);
+  };
+  if (Ty->isDependentType())
+    return false;
+  // isCompleteType is used to force template class instantiation.
+  if (!isCompleteType(CI.getLoc(), Ty))
+    return emitWarning(diag::note_returned_incomplete_type);
+  const RecordDecl *RD = Ty->getAsRecordDecl();
+  if (!RD || RD->isUnion())
+    return emitWarning(diag::note_returned_not_struct);
+  if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+    if (CXXRD->getNumBases() > 0) {
----------------
erichkeane wrote:

> We seem to track them separately:
> 
> https://github.com/llvm/llvm-project/blob/c2b4e481a0504cbb50e83098d2634b063be6b5c9/clang/include/clang/AST/DeclCXX.h#L317
> 
> https://github.com/llvm/llvm-project/blob/c2b4e481a0504cbb50e83098d2634b063be6b5c9/clang/include/clang/AST/DeclCXX.h#L602
> 
> https://github.com/llvm/llvm-project/blob/c2b4e481a0504cbb50e83098d2634b063be6b5c9/clang/include/clang/AST/DeclCXX.h#L320
> 
> https://github.com/llvm/llvm-project/blob/c2b4e481a0504cbb50e83098d2634b063be6b5c9/clang/include/clang/AST/DeclCXX.h#L623

Right, my understanding is `NumBases` is the TOTAL, and `NumVBases` is the 
`number of virtual bases`.



https://github.com/llvm/llvm-project/pull/167010
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to