"README.md" did not exist on "a302ae096e1625af814822cbd204590ec4546d97"
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
Showing
- clang/include/clang/AST/Expr.h 183 additions, 2 deletionsclang/include/clang/AST/Expr.h
- clang/include/clang/AST/StmtNodes.def 1 addition, 0 deletionsclang/include/clang/AST/StmtNodes.def
- clang/include/clang/Checker/PathSensitive/GRExprEngine.h 4 additions, 0 deletionsclang/include/clang/Checker/PathSensitive/GRExprEngine.h
- clang/include/clang/Frontend/PCHBitCodes.h 2 additions, 0 deletionsclang/include/clang/Frontend/PCHBitCodes.h
- clang/include/clang/Frontend/StmtXML.def 8 additions, 1 deletionclang/include/clang/Frontend/StmtXML.def
- clang/lib/AST/Expr.cpp 64 additions, 3 deletionsclang/lib/AST/Expr.cpp
- clang/lib/AST/ExprConstant.cpp 62 additions, 4 deletionsclang/lib/AST/ExprConstant.cpp
- clang/lib/AST/StmtPrinter.cpp 30 additions, 0 deletionsclang/lib/AST/StmtPrinter.cpp
- clang/lib/AST/StmtProfile.cpp 24 additions, 0 deletionsclang/lib/AST/StmtProfile.cpp
- clang/lib/Checker/GRExprEngine.cpp 28 additions, 9 deletionsclang/lib/Checker/GRExprEngine.cpp
- clang/lib/CodeGen/CGExprScalar.cpp 17 additions, 1 deletionclang/lib/CodeGen/CGExprScalar.cpp
- clang/lib/Frontend/PCHReaderStmt.cpp 45 additions, 0 deletionsclang/lib/Frontend/PCHReaderStmt.cpp
- clang/lib/Frontend/PCHWriterStmt.cpp 32 additions, 0 deletionsclang/lib/Frontend/PCHWriterStmt.cpp
- clang/lib/Frontend/StmtXML.cpp 5 additions, 0 deletionsclang/lib/Frontend/StmtXML.cpp
- clang/lib/Sema/Sema.h 5 additions, 0 deletionsclang/lib/Sema/Sema.h
- clang/lib/Sema/SemaChecking.cpp 4 additions, 0 deletionsclang/lib/Sema/SemaChecking.cpp
- clang/lib/Sema/SemaExpr.cpp 173 additions, 32 deletionsclang/lib/Sema/SemaExpr.cpp
- clang/lib/Sema/TreeTransform.h 71 additions, 0 deletionsclang/lib/Sema/TreeTransform.h
- clang/test/PCH/exprs.c 4 additions, 0 deletionsclang/test/PCH/exprs.c
- clang/test/PCH/exprs.h 13 additions, 0 deletionsclang/test/PCH/exprs.h
Loading
Please register or sign in to comment