[llvm-branch-commits] [cfe-branch] r81284 - /cfe/branches/release_26/include/clang/AST/Decl.h

Tanya Lattner tonic at nondot.org
Tue Sep 8 16:39:56 PDT 2009


Author: tbrethou
Date: Tue Sep  8 18:39:56 2009
New Revision: 81284

URL: http://llvm.org/viewvc/llvm-project?rev=81284&view=rev
Log:
Patch to fix PR4061.


Modified:
    cfe/branches/release_26/include/clang/AST/Decl.h

Modified: cfe/branches/release_26/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_26/include/clang/AST/Decl.h?rev=81284&r1=81283&r2=81284&view=diff

==============================================================================
--- cfe/branches/release_26/include/clang/AST/Decl.h (original)
+++ cfe/branches/release_26/include/clang/AST/Decl.h Tue Sep  8 18:39:56 2009
@@ -286,10 +286,12 @@
   /// 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 @@
   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);





More information about the llvm-branch-commits mailing list