aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Sema/Initialization.h
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-04-11 00:58:58 +0000
committerJordan Rose <jordan_rose@apple.com>2013-04-11 00:58:58 +0000
commit1fd1e288d0f45b86d191d8f53f569e5143f3a18a (patch)
tree7f6542a8aec6cf3aee037e976843c2449c1b47b4 /include/clang/Sema/Initialization.h
parent9ae7a92009c468d01d233e6a9f37ab04946864f9 (diff)
Force a load when creating a reference to a temporary copied from a bitfield.
For this source: const int &ref = someStruct.bitfield; We used to generate this AST: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'const int' lvalue <NoOp> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Notice the lvalue inside the MaterializeTemporaryExpr, which is very confusing (and caused an assertion to fire in the analyzer - PR15694). We now generate this: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'int' <LValueToRValue> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Which makes a lot more sense. This allows us to remove code in both CodeGen and AST that hacked around this special case. The commit also makes Clang accept this (legal) C++11 code: int &&ref = std::move(someStruct).bitfield PR15694 / <rdar://problem/13600396> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/Initialization.h')
-rw-r--r--include/clang/Sema/Initialization.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h
index 8459be16f4..9740318e02 100644
--- a/include/clang/Sema/Initialization.h
+++ b/include/clang/Sema/Initialization.h
@@ -594,6 +594,8 @@ public:
SK_QualificationConversionXValue,
/// \brief Perform a qualification conversion, producing an lvalue.
SK_QualificationConversionLValue,
+ /// \brief Perform a load from a glvalue, producing an rvalue.
+ SK_LValueToRValue,
/// \brief Perform an implicit conversion sequence.
SK_ConversionSequence,
/// \brief Perform list-initialization without a constructor
@@ -911,6 +913,12 @@ public:
void AddQualificationConversionStep(QualType Ty,
ExprValueKind Category);
+ /// \brief Add a new step that performs a load of the given type.
+ ///
+ /// Although the term "LValueToRValue" is conventional, this applies to both
+ /// lvalues and xvalues.
+ void AddLValueToRValueStep(QualType Ty);
+
/// \brief Add a new step that applies an implicit conversion sequence.
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS,
QualType T);