[PATCH] D64320: [OpenCL] Print builtin function prototypes if ambiguous
Pierre GONDOIS via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 03:44:39 PDT 2019
Pierre created this revision.
Pierre added reviewers: Anastasia, svenvh.
Pierre added projects: clang, LLVM.
Herald added subscribers: cfe-commits, kristina.
When hitting an ambigous call to a builtin function with the
-fdeclare-opencl-builtins option, diagnostics don't print the prototypes
that clash.
When not using the option above, they are displayed.
This patch prints them.
This is changing this diagnostic:
test.cl:86:11: error: call to 'acos' is ambiguous
int a = acos(p);
^~~~
test.cl:86:11: note: candidate function
test.cl:86:11: note: candidate function
[not printing everything ...]
test.cl:86:11: note: candidate function
1 error generated.
To this:
test.cl:86:11: error: call to 'acos' is ambiguous
int a = acos(p);
^~~~
test.cl:86:11: note: candidate function
float acos(float)
test.cl:86:11: note: candidate function
double acos(double)
[not printing everything ...]
test.cl:86:11: note: candidate function
__fp16 __attribute__((ext_vector_type(16))) acos(__fp16 __attribute__((ext_vector_type(16))))
1 error generated.
Repository:
rC Clang
https://reviews.llvm.org/D64320
Files:
clang/lib/Sema/SemaOverload.cpp
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10425,6 +10425,25 @@
// We don't really have anything else to say about viable candidates.
S.NoteOverloadCandidate(Cand->FoundDecl, Fn);
+
+ // If this is a builtin function, give the available definitions.
+ if (S.getLangOpts().OpenCL && Fn->isImplicit()) {
+ raw_ostream &OS = llvm::outs();
+ unsigned NumParams = Fn->getNumParams();
+
+ OS << Fn->getReturnType().getAsString() << " ";
+ OS << Fn->getNameInfo().getAsString() << "(";
+
+ if (NumParams > 0) {
+ OS << Fn->getParamDecl(0)->getOriginalType().getAsString();
+ }
+ for (unsigned i = 1; i < NumParams; i++) {
+ OS << ", ";
+ OS << Fn->getParamDecl(i)->getOriginalType().getAsString();
+ }
+ OS << ")\n";
+ }
+
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64320.208358.patch
Type: text/x-patch
Size: 963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190708/66db521d/attachment.bin>
More information about the cfe-commits
mailing list