summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2009-09-08 23:39:56 +0000
committerTanya Lattner <tonic@nondot.org>2009-09-08 23:39:56 +0000
commitf386982e3aa9c207606a06adb7f254ab61bf1749 (patch)
tree6acb29f5cda27b287c8ad704a342d4fbf96508d9
parentMerge 81236 from mainline. (diff)
downloadllvm-project-f386982e3aa9c207606a06adb7f254ab61bf1749.tar.gz
llvm-project-f386982e3aa9c207606a06adb7f254ab61bf1749.tar.bz2
llvm-project-f386982e3aa9c207606a06adb7f254ab61bf1749.zip
Patch to fix PR4061.
llvm-svn: 81284
-rw-r--r--clang/include/clang/AST/Decl.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index ae1b8bb25269..861000069294 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -286,10 +286,12 @@ protected:
/// argument.
struct UnparsedDefaultArgument;
+ typedef llvm::PointerUnion3<Stmt *, EvaluatedStmt *,
+ UnparsedDefaultArgument *> InitType;
+
/// \brief The initializer for this variable or, for a ParmVarDecl, the
/// C++ default argument.
- mutable llvm::PointerUnion3<Stmt *, EvaluatedStmt *, UnparsedDefaultArgument*>
- Init;
+ mutable InitType Init;
private:
// FIXME: This can be packed into the bitfields in Decl.
@@ -363,7 +365,15 @@ public:
Stmt **getInitAddress() {
if (EvaluatedStmt *ES = Init.dyn_cast<EvaluatedStmt*>())
return &ES->Value;
- return reinterpret_cast<Stmt **>(&Init); // FIXME: ugly hack
+
+ // This union hack tip-toes around strict-aliasing rules.
+ union {
+ InitType *InitPtr;
+ Stmt **StmtPtr;
+ };
+
+ InitPtr = &Init;
+ return StmtPtr;
}
void setInit(ASTContext &C, Expr *I);