llvm-project/clang/lib/AST
Jordan Rose b1312a5495 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>

llvm-svn: 179250
2013-04-11 00:58:58 +00:00
..
APValue.cpp Don't crash while printing APValues that are lvalues casted to a 2013-01-29 01:26:43 +00:00
ASTConsumer.cpp Sort all of Clang's files under 'lib', and fix up the broken headers 2012-12-04 09:13:33 +00:00
ASTContext.cpp Add an option to parse all comments as documentation comments 2013-04-10 15:35:17 +00:00
ASTDiagnostic.cpp Refactor the Get* functions to be more consistant among themselves. 2013-04-03 03:06:48 +00:00
ASTDumper.cpp Add 178663 back. 2013-04-03 19:27:57 +00:00
ASTImporter.cpp Add 178663 back. 2013-04-03 19:27:57 +00:00
AttrImpl.cpp [ms-cxxabi] Give the MS inheritance attributes a base class 2013-03-26 18:30:28 +00:00
CMakeLists.txt OpenMP threadprivate directive parsing and semantic analysis 2013-03-22 06:34:35 +00:00
CXXABI.h [ms-cxxabi] Correctly compute the size of member pointers 2013-03-28 20:02:56 +00:00
CXXInheritance.cpp Fix Cast 2013-01-15 22:09:40 +00:00
Comment.cpp Replace TypeLoc llvm::cast support to be well-defined. 2013-02-18 22:06:02 +00:00
CommentBriefParser.cpp Some refactoring in my patch on document 2013-03-02 02:39:57 +00:00
CommentCommandTraits.cpp Comment parsing: add CommentOptions to allow specifying custom comment block commands 2013-02-22 14:21:27 +00:00
CommentLexer.cpp Comment parsing: refactor handling of command markers in AST 2013-03-04 23:06:15 +00:00
CommentParser.cpp doc parsing. Add @method and @callback for 2013-03-05 19:40:47 +00:00
CommentSema.cpp documentation comment parsing. Added couple of 2013-03-18 23:45:52 +00:00
Decl.cpp Add hasExternalLinkageUncached back with the test that Richard provided, but 2013-04-04 04:40:17 +00:00
DeclBase.cpp Add 178663 back. 2013-04-03 19:27:57 +00:00
DeclCXX.cpp <rdar://problem/12806802> Propagate access specifiers for conversion functions to the conversion function set eagerly. 2013-04-08 17:12:58 +00:00
DeclFriend.cpp Added outer template parameter lists to friend type AST nodes. 2013-01-31 09:54:08 +00:00
DeclGroup.cpp Sort all of Clang's files under 'lib', and fix up the broken headers 2012-12-04 09:13:33 +00:00
DeclObjC.cpp When looking for overridden ObjC methods, don't ignore 'hidden' ones. 2013-03-29 21:51:48 +00:00
DeclOpenMP.cpp OpenMP threadprivate directive parsing and semantic analysis 2013-03-22 06:34:35 +00:00
DeclPrinter.cpp Add 178663 back. 2013-04-03 19:27:57 +00:00
DeclTemplate.cpp Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList. 2013-02-22 15:46:01 +00:00
DeclarationName.cpp Don't include Type.h in DeclarationName.h. 2012-12-01 16:35:25 +00:00
DumpXML.cpp Revert r175912, "Add support for coldcc to clang" at John's request. 2013-02-23 00:06:18 +00:00
Expr.cpp Add streamed versions of getQualifiedNameAsString. 2013-02-23 13:53:57 +00:00
ExprCXX.cpp ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType. 2013-03-08 21:51:21 +00:00
ExprClassification.cpp Correctly classify T{} as an array temporary if T is an array of class type with nontrivial destructor. 2013-02-02 02:11:36 +00:00
ExprConstant.cpp Force a load when creating a reference to a temporary copied from a bitfield. 2013-04-11 00:58:58 +00:00
ExternalASTSource.cpp Simplify FindExternalVisibleDeclsByName by making it return a bool indicating 2013-02-07 03:30:24 +00:00
InheritViz.cpp Remove an unneeded const_cast 2013-01-14 00:25:25 +00:00
ItaniumCXXABI.cpp [ms-cxxabi] Correctly compute the size of member pointers 2013-03-28 20:02:56 +00:00
ItaniumMangle.cpp Don't crash when mangling types defined in ObjC class extensions. 2013-04-10 06:08:21 +00:00
LambdaMangleContext.cpp ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType. 2013-03-08 21:51:21 +00:00
Makefile
Mangle.cpp Sort all of Clang's files under 'lib', and fix up the broken headers 2012-12-04 09:13:33 +00:00
MicrosoftCXXABI.cpp Make helpers static & 80 cols. 2013-04-04 17:07:04 +00:00
MicrosoftMangle.cpp [ms-cxxabi] Add "$$C" when mangling template arg QualTypes 2013-04-09 12:47:38 +00:00
NSAPI.cpp Use None rather than Optional<T>() where possible. 2013-02-21 01:47:18 +00:00
NestedNameSpecifier.cpp Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList. 2013-02-22 15:46:01 +00:00
ParentMap.cpp ParentMap: Restore the ability to update an existing map. 2012-10-06 01:19:36 +00:00
RawCommentList.cpp Add an option to parse all comments as documentation comments 2013-04-10 15:35:17 +00:00
RecordLayout.cpp First pass at abstracting out a class for the target C++ ABI. 2013-01-25 22:30:49 +00:00
RecordLayoutBuilder.cpp Abstract the behavior of when to use base-class tail padding. 2013-01-29 01:14:22 +00:00
SelectorLocationsKind.cpp Fix crash when using archaic protocol, rdar://10238337 2011-10-05 21:28:06 +00:00
Stmt.cpp Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h. 2013-02-08 22:30:41 +00:00
StmtIterator.cpp Support for C++11 (non-template) alias declarations. 2011-04-15 14:24:37 +00:00
StmtPrinter.cpp Implement compiler intrinsics needed for compatibility with MSVC 2012 <type_traits>. 2013-03-27 01:34:16 +00:00
StmtProfile.cpp Fix the AST representation for non-type template arguments to encode 2012-09-26 02:36:12 +00:00
StmtViz.cpp
TemplateBase.cpp Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList. 2013-02-22 15:46:01 +00:00
TemplateName.cpp Add quotation marks to template names in diagnostics. 2013-03-05 06:21:38 +00:00
Type.cpp [AST] Add a fast path to ConstantArrayType::getNumAddressingBits(). 2013-03-15 20:55:27 +00:00
TypeLoc.cpp Rename TypeLoc's isType to isKind 2013-02-21 01:47:08 +00:00
TypePrinter.cpp Revert r175912, "Add support for coldcc to clang" at John's request. 2013-02-23 00:06:18 +00:00
VTTBuilder.cpp Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used instead. 2012-07-04 18:45:14 +00:00
VTableBuilder.cpp Emit virtual/deleting destructors properly with -cxx-abi microsoft, PR15058 2013-02-13 08:37:51 +00:00