diff options
author | Tanya Lattner <tonic@nondot.org> | 2009-09-08 23:39:56 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2009-09-08 23:39:56 +0000 |
commit | 77d91743a56850cd32585b9b55f4c875970f942e (patch) | |
tree | a60239b1ac43d7c16cc024ab6d919736320c4d5c | |
parent | 2ea79e9a764754de541846f1e286196207479b32 (diff) |
Patch to fix PR4061.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_26@81284 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Decl.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index ae1b8bb252..8610000692 100644 --- a/include/clang/AST/Decl.h +++ b/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); |