[PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.
Hans Wennborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 02:07:54 PDT 2020
hans added a comment.
Okay, since checking this is cheap I suppose we can do it.
================
Comment at: clang/lib/Analysis/UninitializedValues.cpp:410
+ if (FunctionDecl *fd = CE->getDirectCallee()) {
+ if (FunctionTemplateDecl *ftd = fd->getPrimaryTemplate())
+ return ftd->getTemplatedDecl()->hasTrivialBody();
----------------
Is this special check for templates necessary? Doesn't the "fd->hasTrivialBody()" check below also handle the template case?
================
Comment at: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp:13
+template <class T>
+inline void ignore_template(T const &) {}
+void ignore(const int &i) {}
----------------
I think "const T &" would be the more common ordering. Also the "inline" isn't really necessary.
================
Comment at: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp:40
+
+ int l;
+ ignore_template(l);
----------------
I would add a comment explaining that this is a pattern to avoid "unused variable" warnings, and mention the boost function as an example.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82425/new/
https://reviews.llvm.org/D82425
More information about the cfe-commits
mailing list