[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed
Serge Rogatch via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 06:58:21 PDT 2016
rSerge added inline comments.
Comment at: lib/Driver/Tools.cpp:4777-4780
@@ +4776,6 @@
+ std::string Feature(XRayInstrumentOption);
+ Feature += " on ";
+ Feature += Triple.getArchName().data();
+ D.Diag(diag::err_drv_clang_unsupported) << Feature;
> Wouldn't something like this work better:
> D.Diag(...) << XRayInstrumentOption << " on " << Triple.getArchName();
No, it doesn't work this way. Although `D.Diag` looks like a C++ stream because of overloaded `<<` operator, it works like C `printf` and `diag::err_drv_clang_unsupported` is like a format specifier. The latter specifies that only the first argument added via `operator<<` is included in the final message. So we have to pass in one string everything we want to say. And LLVM coding guidelines forbid C++ streams.
More information about the cfe-commits