================
@@ -993,6 +993,87 @@ UnwindTagContext(TagDecl *DC, api_notes::APINotesManager
&APINotes) {
return std::nullopt;
}
+static void stripAPINotesParameterNullability(QualType &ParamType) {
+ while (true) {
+ if (!AttributedType::stripOuterNullability(ParamType))
+ return;
+ }
+}
+
+// Print the APINotes selector spelling for one parameter. The source-spelled
+// selector is tried first. The desugared spelling is only a permissive
+// fallback.
+static std::string getAPINotesParameterSelectorSpelling(
+ QualType ParamType, const ASTContext &Context, const PrintingPolicy
&Policy,
+ bool Desugar) {
+ ParamType.removeLocalConst();
+ stripAPINotesParameterNullability(ParamType);
+
+ if (Desugar) {
+ ParamType = ParamType.getDesugaredType(Context);
+ ParamType.removeLocalConst();
+ stripAPINotesParameterNullability(ParamType);
+ }
+
+ return ParamType.getAsString(Policy);
+}
+
+static std::optional<SmallVector<SmallVector<std::string, 4>, 2>>
+getAPINotesParameterSelectorCandidates(const Sema &S, const FunctionDecl *FD) {
+ const auto *FPT = FD->getType()->getAs<FunctionProtoType>();
+ if (!FPT)
+ return std::nullopt;
+
+ SmallVector<std::string, 4> SourceParameters;
+ SmallVector<std::string, 4> DesugaredParameters;
+ SourceParameters.reserve(FPT->getNumParams());
+ DesugaredParameters.reserve(FPT->getNumParams());
+
+ const PrintingPolicy &Policy = S.Context.getPrintingPolicy();
----------------
StoeckOverflow wrote:
On the `QualType` point, I see what you mean. I’ll look into moving selector
candidate formation into `processExactAPINotes`, so the call sites pass the
declaration parameter `QualType`s instead of precomputed selector strings. The
reader lookup would still use strings for now because the binary keys are
string-based, but the printing/normalization policy would live at the
exact-match boundary.
Do you think that should be folded into this PR, or would you be comfortable
leaving it for a follow-up cleanup?
https://github.com/llvm/llvm-project/pull/205307
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits