Update NRVO logic to support early return (Attempt 2)
authorTaiju Tsuiki <tzik@google.com>
Tue, 19 Jun 2018 04:39:07 +0000 (04:39 +0000)
committerTaiju Tsuiki <tzik@google.com>
Tue, 19 Jun 2018 04:39:07 +0000 (04:39 +0000)
commitb000a8860e9ec26f4a2834dbeaba44cd27025306
treeacb0e6018e9e3cfc7fc0c3efaf2eace9de21fb69
parentc2965214efbd35ed54e08cce042e8eed778646aa
Update NRVO logic to support early return (Attempt 2)

Summary:
This is the second attempt of r333500 (Update NRVO logic to support early return).
The previous one was reverted for a miscompilation for an incorrect NRVO set up on templates such as:
```
struct Foo {};

template <typename T>
T bar() {
  T t;
  if (false)
    return T();
  return t;
}
```

Where, `t` is marked as non-NRVO variable before its instantiation. However, while its instantiation, it's left an NRVO candidate, turned into an NRVO variable later.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 335019
12 files changed:
clang/include/clang/AST/Decl.h
clang/include/clang/Sema/Scope.h
clang/lib/Sema/Scope.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CodeGenCXX/nrvo-noopt.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/nrvo.cpp
clang/test/SemaCXX/nrvo-ast.cpp [new file with mode: 0644]