Do not consider builtins to be inference targets.
Also remove unneeded reference stripping from an expression type which can never be a reference type.
PiperOrigin-RevId: 563471940
Change-Id: Ib1b84988e598c11d81d571818341fdf137e33763
diff --git a/nullability/inference/collect_evidence.cc b/nullability/inference/collect_evidence.cc
index a4efd97..2afd92b 100644
--- a/nullability/inference/collect_evidence.cc
+++ b/nullability/inference/collect_evidence.cc
@@ -172,8 +172,7 @@
CalleeDecl->getParamDecl(ParamI)->getType().getNonReferenceType()))
continue;
// the corresponding argument should also be a pointer.
- CHECK(isSupportedPointerType(
- CallExpr->getArg(ArgI)->getType().getNonReferenceType()));
+ CHECK(isSupportedPointerType(CallExpr->getArg(ArgI)->getType()));
dataflow::PointerValue *PV =
getPointerValueFromExpr(CallExpr->getArg(ArgI), Env);
diff --git a/nullability/inference/inferrable.cc b/nullability/inference/inferrable.cc
index e41c6e6..cccc2df 100644
--- a/nullability/inference/inferrable.cc
+++ b/nullability/inference/inferrable.cc
@@ -46,7 +46,14 @@
// itself. We can't record them anywhere unless they apply to the
// template in general.
// TODO: work out in what circumstances that would be safe.
- !FD->getTemplateInstantiationPattern();
+ !FD->getTemplateInstantiationPattern() &&
+ // builtins can't be annotated and are irregular in their type checking
+ // and in other ways, leading to violations of otherwise sound
+ // assumptions.
+ // If we find that their nullability is unexpectedly leaking into
+ // programs under analysis in significant ways, we can hardcode this small
+ // set of functions.
+ FD->getBuiltinID() == 0;
}
} // namespace clang::tidy::nullability