diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/system/coroutines.h @@ -0,0 +1,34 @@ +#pragma once + +namespace std { +namespace experimental { + +template +struct coroutine_traits { + using promise_type = typename ret_t::promise_type; +}; + +template +struct coroutine_handle { + static constexpr coroutine_handle from_address(void *addr) noexcept { return {}; }; +}; + +} // namespace experimental +} // namespace std + +struct never_suspend { + bool await_ready() noexcept { return false; } + template + void await_suspend(coro_t handle) noexcept {} + void await_resume() noexcept {} +}; + +struct task { + struct promise_type { + task get_return_object() noexcept { return {}; } + never_suspend initial_suspend() noexcept { return {}; } + never_suspend final_suspend() noexcept { return {}; } + void return_void() {} + void unhandled_exception() {} + }; +}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp @@ -81,13 +81,14 @@ // RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \ // RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \ // RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \ -// RUN: ]}' -- -fno-delayed-template-parsing -Dbad_macro \ +// RUN: ]}' -- -fno-delayed-template-parsing -Dbad_macro -std=c++17 -fcoroutines-ts \ // RUN: -I%S/Inputs/readability-identifier-naming \ // RUN: -isystem %S/Inputs/readability-identifier-naming/system // clang-format off #include +#include #include "user-header.h" // NO warnings or fixes expected from declarations within header files without // the -header-filter= option @@ -287,7 +288,7 @@ // Overriding a badly-named base isn't a new violation. void BadBaseMethod() override {} // CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {} - + void foo() { BadBaseMethod(); // CHECK-FIXES: {{^}} v_Bad_Base_Method(); @@ -614,3 +615,14 @@ auto GetRes(type_t& Param) -> decltype(Param.res()); // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param' // CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res()); + +// Check implicit declarations in coroutines + +struct async_obj { +public: + never_suspend operator co_await() const noexcept; +}; + +task ImplicitDeclTest(async_obj &a_object) { + co_await a_object; // CHECK-MESSAGES-NOT: warning: invalid case style for local variable +} diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -544,6 +544,7 @@ auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(), &PP.getIdentifierTable().get("__promise"), T, Context.getTrivialTypeSourceInfo(T, Loc), SC_None); + VD->setImplicit(); CheckVariableDeclarationType(VD); if (VD->isInvalidDecl()) return nullptr; @@ -1577,6 +1578,7 @@ S.Context, &FD, FD.getLocation(), FD.getLocation(), &S.PP.getIdentifierTable().get("__coro_gro"), GroType, S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None); + GroDecl->setImplicit(); S.CheckVariableDeclarationType(GroDecl); if (GroDecl->isInvalidDecl())