[all-commits] [llvm/llvm-project] 2aa433: [flang] Fix copy elision assumption.
Michael Kruse via All-commits
all-commits at lists.llvm.org
Mon Dec 14 12:12:45 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 2aa43358060c6b34fb9cdc6c4321e958f62331e7
https://github.com/llvm/llvm-project/commit/2aa43358060c6b34fb9cdc6c4321e958f62331e7
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2020-12-14 (Mon, 14 Dec 2020)
Changed paths:
M flang/include/flang/Common/restorer.h
M flang/lib/Semantics/check-declarations.cpp
Log Message:
-----------
[flang] Fix copy elision assumption.
Before this patch, the Restorer depended on copy elision to happen.
Without copy elision, the function ScopedSet calls the move constructor
before its dtor. The dtor will prematurely restore the reference to the
original value.
Instead of relying the compiler to not use the Restorer's copy
constructor, delete its copy and assign operators. Hence, callers cannot
move or copy a Restorer object anymore, and have to explicitly provide
the reset state. ScopedSet avoids calling move/copy operations by
relying on unnamed return value optimization, which is mandatory in
C++17.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D88797
More information about the All-commits
mailing list