]> granicus.if.org Git - clang/commit
[Coroutines] Find custom allocators in class scope
authorBrian Gesiak <modocache@gmail.com>
Sun, 1 Apr 2018 22:59:22 +0000 (22:59 +0000)
committerBrian Gesiak <modocache@gmail.com>
Sun, 1 Apr 2018 22:59:22 +0000 (22:59 +0000)
commitd2efb713d778dd79287928fcd897b46b4bd00b10
treef544199a1359f6194344c6f6b7829547758191ee
parent4448880e1818ce0dfffc0178be3a52bf5533be05
[Coroutines] Find custom allocators in class scope

Summary:
https://reviews.llvm.org/rL325291 implemented Coroutines TS N4723
section [dcl.fct.def.coroutine]/7, but it performed lookup of allocator
functions within both the global and class scope, whereas the specified
behavior is to perform lookup for custom allocators within just the
class scope.

To fix, add parameters to the `Sema::FindAllocationFunctions` function
such that it can be used to lookup allocators in global scope,
class scope, or both (instead of just being able to look up in just global
scope or in both global and class scope). Then, use those parameters
from within the coroutine Sema.

This incorrect behavior had the unfortunate side-effect of causing the
bug https://bugs.llvm.org/show_bug.cgi?id=36578 (or at least the reports
of that bug in C++ programs). That bug would occur for any C++ user with
a coroutine frame that took a single pointer argument, since it would
then find the global placement form `operator new`, described in the
C++ standard 18.6.1.3.1. This patch prevents Clang from generating code
that triggers the LLVM assert described in that bug report.

Test Plan: `check-clang`

Reviewers: GorNishanov, eric_niebler, lewissbaker

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

Differential Revision: https://reviews.llvm.org/D44552

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328949 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/Sema.h
lib/Sema/SemaCoroutine.cpp
lib/Sema/SemaExprCXX.cpp
test/CodeGenCoroutines/coro-alloc.cpp
test/SemaCXX/coroutines.cpp