[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 05:17:04 PDT 2024


================
@@ -2438,6 +2438,22 @@ bool Type::isIncompleteType(NamedDecl **Def) const {
   }
 }
 
+bool Type::isIncompletableIncompleteType() const {
+  if (!isIncompleteType())
+    return false;
+
+  // Forward declarations of structs, classes, enums, and unions could be later
+  // completed in a compilation unit by providing a type definition.
+  if (isStructureOrClassType() || isEnumeralType() || isUnionType())
+    return false;
+
+  // Other types are incompletable.
+  //
+  // E.g. `char[]` and `void`. The type is incomplete and no future
+  // type declarations can make the type complete.
+  return true;
+}
+
----------------
Sirraide wrote:

I think all of this can just be
```
TagDecl *TD = getAsTagDecl();
return isIncompleteType() && TD && !TD->isCompleteDefinition()
```
Since it’s only called in one place, I think we can just inline this and delete this function entirely?

https://github.com/llvm/llvm-project/pull/106321


More information about the cfe-commits mailing list