Mark implicit coroutine variables as being implicit
This prevents the clang-tidy readability-identifier-naming check from triggering on implicit __coro_gro and __promise variables in coroutines.
This commit is contained in:
parent
900d71a851
commit
7685d818ef
|
@ -0,0 +1,34 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
namespace experimental {
|
||||||
|
|
||||||
|
template <typename ret_t, typename... args_t>
|
||||||
|
struct coroutine_traits {
|
||||||
|
using promise_type = typename ret_t::promise_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class promise_t>
|
||||||
|
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 <typename coro_t>
|
||||||
|
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() {}
|
||||||
|
};
|
||||||
|
};
|
|
@ -81,13 +81,14 @@
|
||||||
// RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
|
// RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
|
||||||
// RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
|
// RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
|
||||||
// RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \
|
// 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: -I%S/Inputs/readability-identifier-naming \
|
||||||
// RUN: -isystem %S/Inputs/readability-identifier-naming/system
|
// RUN: -isystem %S/Inputs/readability-identifier-naming/system
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#include <system-header.h>
|
#include <system-header.h>
|
||||||
|
#include <coroutines.h>
|
||||||
#include "user-header.h"
|
#include "user-header.h"
|
||||||
// NO warnings or fixes expected from declarations within header files without
|
// NO warnings or fixes expected from declarations within header files without
|
||||||
// the -header-filter= option
|
// the -header-filter= option
|
||||||
|
@ -287,7 +288,7 @@ public:
|
||||||
// Overriding a badly-named base isn't a new violation.
|
// Overriding a badly-named base isn't a new violation.
|
||||||
void BadBaseMethod() override {}
|
void BadBaseMethod() override {}
|
||||||
// CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {}
|
// CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {}
|
||||||
|
|
||||||
void foo() {
|
void foo() {
|
||||||
BadBaseMethod();
|
BadBaseMethod();
|
||||||
// CHECK-FIXES: {{^}} v_Bad_Base_Method();
|
// CHECK-FIXES: {{^}} v_Bad_Base_Method();
|
||||||
|
@ -614,3 +615,14 @@ template<typename type_t>
|
||||||
auto GetRes(type_t& Param) -> decltype(Param.res());
|
auto GetRes(type_t& Param) -> decltype(Param.res());
|
||||||
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param'
|
// 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-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
|
||||||
|
}
|
||||||
|
|
|
@ -544,6 +544,7 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
|
||||||
auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
|
auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
|
||||||
&PP.getIdentifierTable().get("__promise"), T,
|
&PP.getIdentifierTable().get("__promise"), T,
|
||||||
Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
|
Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
|
||||||
|
VD->setImplicit();
|
||||||
CheckVariableDeclarationType(VD);
|
CheckVariableDeclarationType(VD);
|
||||||
if (VD->isInvalidDecl())
|
if (VD->isInvalidDecl())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1577,6 +1578,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
|
||||||
S.Context, &FD, FD.getLocation(), FD.getLocation(),
|
S.Context, &FD, FD.getLocation(), FD.getLocation(),
|
||||||
&S.PP.getIdentifierTable().get("__coro_gro"), GroType,
|
&S.PP.getIdentifierTable().get("__coro_gro"), GroType,
|
||||||
S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
|
S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
|
||||||
|
GroDecl->setImplicit();
|
||||||
|
|
||||||
S.CheckVariableDeclarationType(GroDecl);
|
S.CheckVariableDeclarationType(GroDecl);
|
||||||
if (GroDecl->isInvalidDecl())
|
if (GroDecl->isInvalidDecl())
|
||||||
|
|
Loading…
Reference in New Issue