brycel added a comment. In https://reviews.llvm.org/D33497#763307, @lebedev.ri wrote:
> 1. What about `__PRETTY_FUNCTION__` ? `__PRETTY_FUNCTION__` is a little more useful, it at least tells you which function the lambda is defined in: #include <stdio.h> int main() { auto f = [] { printf("__func__: %s\n", __func__); printf("__FUNCTION__: %s\n", __FUNCTION__); printf("__PRETTY_FUNCTION__: %s\n", __PRETTY_FUNCTION__); }; f(); } results in the output: __func__: operator() __FUNCTION__: operator() __PRETTY_FUNCTION__: auto main()::(anonymous class)::operator()() const I think `__PRETTY_FUNCTION__` inside a lambda is useful enough not to warn about. > 2. Consider following generic error handling macro: (ThrowException is some > template function) ``` #undef STR #define STR(a) XSTR(a) > > #define ThrowExceptionHelper(CLASS, fmt, ...) > ThrowException<CLASS>(__FILE__ ":" STR(__LINE__) ": %s: " fmt, > __PRETTY_FUNCTION__, ##__VA_ARGS__) #endif ``` Which is called like > `if(somethig) ThrowException(std::exception, "%s", "bar");` Even though the > function name may be useless, file/line info is still there and is(?) > correct. Perhaps there should not be a warning in such a case? That's a good point. I'll look into suppressing the warning if we're in a macro definition where `__FILE__` and `__LINE__` are both used. It may suppress some warnings that would be legitimate (such as if `__FILE__`/`__LINE__` are written but not actually output anywhere), but in those cases it's probably impossible to figure out the author's intention. https://reviews.llvm.org/D33497 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits