diff options
author | James Y Knight <jyknight@google.com> | 2015-07-17 18:21:37 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2015-07-17 18:21:37 +0000 |
commit | 53c7616e2e6aa3bcef0123c1890f8fdeb0e760ab (patch) | |
tree | 7e9e1de25a2500e592ba668b4405ce2a07ba1378 /clang/lib/AST/ExprCXX.cpp | |
parent | 5a6d5bc17b385293e3337b9f2082151594f972f9 (diff) | |
download | bcm5719-llvm-53c7616e2e6aa3bcef0123c1890f8fdeb0e760ab.tar.gz bcm5719-llvm-53c7616e2e6aa3bcef0123c1890f8fdeb0e760ab.zip |
Fix alignment issues in Clang.
Some const-correctness changes snuck in here too, since they were in the
area of code I was modifying.
This seems to make Clang actually work without Bus Error on
32bit-sparc.
Follow-up patches will factor out a trailing-object helper class, to
make classes using the idiom of appending objects to other objects
easier to understand, and to ensure (with static_assert) that required
alignment guarantees continue to hold.
Differential Revision: http://reviews.llvm.org/D10272
llvm-svn: 242554
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index d6f2ce63a0a..2a93f71429e 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1070,15 +1070,15 @@ LambdaExpr::capture_range LambdaExpr::implicit_captures() const { return capture_range(implicit_capture_begin(), implicit_capture_end()); } -ArrayRef<VarDecl *> -LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { +ArrayRef<VarDecl *> +LambdaExpr::getCaptureInitIndexVars(const_capture_init_iterator Iter) const { assert(HasArrayIndexVars && "No array index-var data?"); unsigned Index = Iter - capture_init_begin(); assert(Index < getLambdaClass()->getLambdaData().NumCaptures && "Capture index out-of-range"); - VarDecl **IndexVars = getArrayIndexVars(); - unsigned *IndexStarts = getArrayIndexStarts(); + VarDecl *const *IndexVars = getArrayIndexVars(); + const unsigned *IndexStarts = getArrayIndexStarts(); return llvm::makeArrayRef(IndexVars + IndexStarts[Index], IndexVars + IndexStarts[Index + 1]); } @@ -1099,9 +1099,13 @@ TemplateParameterList *LambdaExpr::getTemplateParameterList() const { } CompoundStmt *LambdaExpr::getBody() const { + // FIXME: this mutation in getBody is bogus. It should be + // initialized in ASTStmtReader::VisitLambdaExpr, but for reasons I + // don't understand, that doesn't work. if (!getStoredStmts()[NumCaptures]) - getStoredStmts()[NumCaptures] = getCallOperator()->getBody(); - + *const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) = + getCallOperator()->getBody(); + return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); } |