[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check
Bernhard Manfred Gruber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 22 16:41:16 PST 2019
bernhardmgruber added a comment.
Thank you again @JonasToth for all your valueable input! I could almost successfully run my check on the llvm/lib subfolder. I created a compilation database from within Visual Studio using an extension called SourceTrail <https://www.sourcetrail.com/blog/export_clang_compilation_database_from_visual_studio_solution/>. One of the issues was the following:
struct Object { long long value; };
class C {
int Object;
struct Object m();
};
Object C::m() { return {0}; }
If I rewrite this to the following
struct Object { long long value; };
class C {
int Object;
struct Object m();
};
auto C::m() -> Object { return {0}; }
a compilation error occurs afterwards, because Object now refers to the class member. I discovered a similar problem colliding with the name of a function argument. So essentially, I believe I now require a name lookup of the return type (if it is unqualified) in the scope of the function. In case such a name already exists, i have to prefix `struct/class` or perform no replacement. I looked at the documentation of `ASTContext`, but it seems all the good stuff is in `DeclContext`, which I have not available. How can I perform a name lookup inside the `check` member function?
Thank you for any tips! And thank you for the `decltype` hint, I will add some more tests.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56160/new/
https://reviews.llvm.org/D56160
More information about the cfe-commits
mailing list