svn commit: r206275 - in vendor/clang/dist: examples/wpa include/clang/AST include/clang/Basic include/clang/Frontend include/clang/Parse lib/AST lib/Checker lib/CodeGen lib/Frontend lib/Lex lib/Pa...

Roman Divacky rdivacky at FreeBSD.org
Tue Apr 6 15:54:00 UTC 2010


Author: rdivacky
Date: Tue Apr  6 15:53:59 2010
New Revision: 206275
URL: http://svn.freebsd.org/changeset/base/206275

Log:
  Update clang to r100520.

Added:
  vendor/clang/dist/lib/Runtime/
  vendor/clang/dist/lib/Runtime/Makefile
  vendor/clang/dist/test/Analysis/inline4.c
  vendor/clang/dist/test/CodeGenObjC/property-dbg.m
  vendor/clang/dist/test/Index/complete-enums.c
  vendor/clang/dist/test/Index/complete-macros.c
Modified:
  vendor/clang/dist/examples/wpa/clang-wpa.cpp
  vendor/clang/dist/include/clang/AST/PrettyPrinter.h
  vendor/clang/dist/include/clang/Basic/Diagnostic.h
  vendor/clang/dist/include/clang/Frontend/ASTUnit.h
  vendor/clang/dist/include/clang/Frontend/CompilerInstance.h
  vendor/clang/dist/include/clang/Parse/Parser.h
  vendor/clang/dist/lib/AST/ASTImporter.cpp
  vendor/clang/dist/lib/AST/Stmt.cpp
  vendor/clang/dist/lib/AST/TypePrinter.cpp
  vendor/clang/dist/lib/Checker/BugReporter.cpp
  vendor/clang/dist/lib/Checker/Environment.cpp
  vendor/clang/dist/lib/CodeGen/CGBuiltin.cpp
  vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp
  vendor/clang/dist/lib/CodeGen/CGDecl.cpp
  vendor/clang/dist/lib/CodeGen/CGExpr.cpp
  vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp
  vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp
  vendor/clang/dist/lib/CodeGen/CGObjC.cpp
  vendor/clang/dist/lib/CodeGen/CGObjCMac.cpp
  vendor/clang/dist/lib/CodeGen/CGObjCRuntime.h
  vendor/clang/dist/lib/CodeGen/CGRecordLayout.h
  vendor/clang/dist/lib/CodeGen/CGRecordLayoutBuilder.cpp
  vendor/clang/dist/lib/CodeGen/CGValue.h
  vendor/clang/dist/lib/CodeGen/CodeGenFunction.cpp
  vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp
  vendor/clang/dist/lib/CodeGen/CodeGenModule.h
  vendor/clang/dist/lib/Frontend/ASTMerge.cpp
  vendor/clang/dist/lib/Frontend/ASTUnit.cpp
  vendor/clang/dist/lib/Frontend/CompilerInstance.cpp
  vendor/clang/dist/lib/Frontend/FrontendAction.cpp
  vendor/clang/dist/lib/Frontend/PCHReader.cpp
  vendor/clang/dist/lib/Lex/Preprocessor.cpp
  vendor/clang/dist/lib/Parse/ParseDecl.cpp
  vendor/clang/dist/lib/Parse/ParseStmt.cpp
  vendor/clang/dist/lib/Sema/CodeCompleteConsumer.cpp
  vendor/clang/dist/lib/Sema/SemaCodeComplete.cpp
  vendor/clang/dist/lib/Sema/SemaObjCProperty.cpp
  vendor/clang/dist/test/CodeGen/asm.c
  vendor/clang/dist/test/CodeGen/builtin-memfns.c
  vendor/clang/dist/test/CodeGenCXX/eh.cpp
  vendor/clang/dist/test/CodeGenCXX/new.cpp
  vendor/clang/dist/test/CodeGenCXX/value-init.cpp
  vendor/clang/dist/test/Makefile
  vendor/clang/dist/test/Parser/cxx-decl.cpp
  vendor/clang/dist/tools/CIndex/CIndex.cpp
  vendor/clang/dist/tools/CIndex/CIndexCodeCompletion.cpp
  vendor/clang/dist/tools/CIndex/CIndexDiagnostic.cpp
  vendor/clang/dist/tools/driver/cc1_main.cpp

Modified: vendor/clang/dist/examples/wpa/clang-wpa.cpp
==============================================================================
--- vendor/clang/dist/examples/wpa/clang-wpa.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/examples/wpa/clang-wpa.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -17,6 +17,7 @@
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Index/CallGraph.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
@@ -34,12 +35,11 @@ int main(int argc, char **argv) {
     return 0;
 
   DiagnosticOptions DiagOpts;
-  llvm::OwningPtr<Diagnostic> Diags(
-    CompilerInstance::createDiagnostics(DiagOpts, argc, argv));
-
+  llvm::IntrusiveRefCntPtr<Diagnostic> Diags
+    = CompilerInstance::createDiagnostics(DiagOpts, argc, argv);
   for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
     const std::string &InFile = InputFilenames[i];
-    llvm::OwningPtr<ASTUnit> AST(ASTUnit::LoadFromPCHFile(InFile, *Diags));
+    llvm::OwningPtr<ASTUnit> AST(ASTUnit::LoadFromPCHFile(InFile, Diags));
     if (!AST)
       return 1;
 

Modified: vendor/clang/dist/include/clang/AST/PrettyPrinter.h
==============================================================================
--- vendor/clang/dist/include/clang/AST/PrettyPrinter.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/include/clang/AST/PrettyPrinter.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -37,7 +37,8 @@ struct PrintingPolicy {
   PrintingPolicy(const LangOptions &LO)
     : Indentation(2), LangOpts(LO), SuppressSpecifiers(false),
       SuppressTag(false), SuppressScope(false),
-      Dump(false), ConstantArraySizeAsWritten(false) { }
+      Dump(false), ConstantArraySizeAsWritten(false),
+      AnonymousTagLocations(true) { }
 
   /// \brief The number of spaces to use to indent each line.
   unsigned Indentation : 8;
@@ -97,7 +98,11 @@ struct PrintingPolicy {
   /// char a[9] = "A string";
   /// \endcode
   bool ConstantArraySizeAsWritten : 1;
-
+  
+  /// \brief When printing an anonymous tag name, also print the location of
+  /// that entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just 
+  /// prints "<anonymous>" for the name.
+  bool AnonymousTagLocations : 1;
 };
 
 } // end namespace clang

Modified: vendor/clang/dist/include/clang/Basic/Diagnostic.h
==============================================================================
--- vendor/clang/dist/include/clang/Basic/Diagnostic.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/include/clang/Basic/Diagnostic.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_DIAGNOSTIC_H
 
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/type_traits.h"
 #include <string>
@@ -150,7 +151,7 @@ public:
 /// problems and issues.  It massages the diagnostics (e.g. handling things like
 /// "report warnings as errors" and passes them off to the DiagnosticClient for
 /// reporting to the user.
-class Diagnostic {
+class Diagnostic : public llvm::RefCountedBase<Diagnostic> {
 public:
   /// Level - The level of the diagnostic, after it has been through mapping.
   enum Level {

Modified: vendor/clang/dist/include/clang/Frontend/ASTUnit.h
==============================================================================
--- vendor/clang/dist/include/clang/Frontend/ASTUnit.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/include/clang/Frontend/ASTUnit.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -16,6 +16,7 @@
 
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Index/ASTLocation.h"
@@ -52,10 +53,9 @@ public:
   typedef std::map<FileID, std::vector<PreprocessedEntity *> > 
     PreprocessedEntitiesByFileMap;
 private:
-  
-  FileManager FileMgr;
-
-  SourceManager                     SourceMgr;
+  llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics;
+  llvm::OwningPtr<FileManager>      FileMgr;
+  llvm::OwningPtr<SourceManager>    SourceMgr;
   llvm::OwningPtr<HeaderSearch>     HeaderInfo;
   llvm::OwningPtr<TargetInfo>       Target;
   llvm::OwningPtr<Preprocessor>     PP;
@@ -90,7 +90,7 @@ private:
 
   /// \brief The set of diagnostics produced when creating this
   /// translation unit.
-  llvm::SmallVector<StoredDiagnostic, 4> Diagnostics;
+  llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
 
   /// \brief Temporary files that should be removed when the ASTUnit is 
   /// destroyed.
@@ -118,6 +118,8 @@ private:
   ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT
   ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT
   
+  explicit ASTUnit(bool MainFileIsAST);
+
 public:
   class ConcurrencyCheck {
     volatile ASTUnit &Self;
@@ -137,13 +139,15 @@ public:
   };
   friend class ConcurrencyCheck;
   
-  ASTUnit(Diagnostic &Diag, bool MainFileIsAST);
   ~ASTUnit();
 
   bool isMainFileAST() const { return MainFileIsAST; }
 
-  const SourceManager &getSourceManager() const { return SourceMgr; }
-        SourceManager &getSourceManager()       { return SourceMgr; }
+  const Diagnostic &getDiagnostics() const { return *Diagnostics; }
+  Diagnostic &getDiagnostics()             { return *Diagnostics; }
+  
+  const SourceManager &getSourceManager() const { return *SourceMgr; }
+        SourceManager &getSourceManager()       { return *SourceMgr; }
 
   const Preprocessor &getPreprocessor() const { return *PP.get(); }
         Preprocessor &getPreprocessor()       { return *PP.get(); }
@@ -151,8 +155,8 @@ public:
   const ASTContext &getASTContext() const { return *Ctx.get(); }
         ASTContext &getASTContext()       { return *Ctx.get(); }
 
-  const FileManager &getFileManager() const { return FileMgr; }
-        FileManager &getFileManager()       { return FileMgr; }
+  const FileManager &getFileManager() const { return *FileMgr; }
+        FileManager &getFileManager()       { return *FileMgr; }
 
   const std::string &getOriginalSourceFileName();
   const std::string &getPCHFileName();
@@ -185,12 +189,17 @@ public:
   }
   
   // Retrieve the diagnostics associated with this AST
-  typedef const StoredDiagnostic * diag_iterator;
-  diag_iterator diag_begin() const { return Diagnostics.begin(); }
-  diag_iterator diag_end() const { return Diagnostics.end(); }
-  unsigned diag_size() const { return Diagnostics.size(); }
-  llvm::SmallVector<StoredDiagnostic, 4> &getDiagnostics() { 
-    return Diagnostics; 
+  typedef const StoredDiagnostic *stored_diag_iterator;
+  stored_diag_iterator stored_diag_begin() const { 
+    return StoredDiagnostics.begin(); 
+  }
+  stored_diag_iterator stored_diag_end() const { 
+    return StoredDiagnostics.end(); 
+  }
+  unsigned stored_diag_size() const { return StoredDiagnostics.size(); }
+  
+  llvm::SmallVector<StoredDiagnostic, 4> &getStoredDiagnostics() { 
+    return StoredDiagnostics; 
   }
 
   /// \brief A mapping from a file name to the memory buffer that stores the
@@ -206,7 +215,7 @@ public:
   ///
   /// \returns - The initialized ASTUnit or null if the PCH failed to load.
   static ASTUnit *LoadFromPCHFile(const std::string &Filename,
-                                  Diagnostic &Diags,
+                                  llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
                                   bool OnlyLocalDecls = false,
                                   RemappedFile *RemappedFiles = 0,
                                   unsigned NumRemappedFiles = 0,
@@ -224,7 +233,7 @@ public:
   // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
   // shouldn't need to specify them at construction time.
   static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI,
-                                             Diagnostic &Diags,
+                                     llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
                                              bool OnlyLocalDecls = false,
                                              bool CaptureDiagnostics = false);
 
@@ -244,7 +253,7 @@ public:
   // shouldn't need to specify them at construction time.
   static ASTUnit *LoadFromCommandLine(const char **ArgBegin,
                                       const char **ArgEnd,
-                                      Diagnostic &Diags,
+                                    llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
                                       llvm::StringRef ResourceFilesPath,
                                       bool OnlyLocalDecls = false,
                                       RemappedFile *RemappedFiles = 0,

Modified: vendor/clang/dist/include/clang/Frontend/CompilerInstance.h
==============================================================================
--- vendor/clang/dist/include/clang/Frontend/CompilerInstance.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/include/clang/Frontend/CompilerInstance.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_
 
 #include "clang/Frontend/CompilerInvocation.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/OwningPtr.h"
 #include <cassert>
@@ -63,7 +64,7 @@ class CompilerInstance {
   llvm::OwningPtr<CompilerInvocation> Invocation;
 
   /// The diagnostics engine instance.
-  llvm::OwningPtr<Diagnostic> Diagnostics;
+  llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics;
 
   /// The diagnostics client instance.
   llvm::OwningPtr<DiagnosticClient> DiagClient;
@@ -255,10 +256,6 @@ public:
     return *Diagnostics;
   }
 
-  /// takeDiagnostics - Remove the current diagnostics engine and give ownership
-  /// to the caller.
-  Diagnostic *takeDiagnostics() { return Diagnostics.take(); }
-
   /// setDiagnostics - Replace the current diagnostics engine; the compiler
   /// instance takes ownership of \arg Value.
   void setDiagnostics(Diagnostic *Value);
@@ -469,8 +466,8 @@ public:
   /// must extend past that of the diagnostic engine.
   ///
   /// \return The new object on success, or null on failure.
-  static Diagnostic *createDiagnostics(const DiagnosticOptions &Opts,
-                                       int Argc, char **Argv);
+  static llvm::IntrusiveRefCntPtr<Diagnostic> 
+  createDiagnostics(const DiagnosticOptions &Opts, int Argc, char **Argv);
 
   /// Create the file manager and replace any existing one with it.
   void createFileManager();

Modified: vendor/clang/dist/include/clang/Parse/Parser.h
==============================================================================
--- vendor/clang/dist/include/clang/Parse/Parser.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/include/clang/Parse/Parser.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -1086,7 +1086,8 @@ private:
                                   CXX0XAttributeList Attr);
   DeclGroupPtrTy ParseSimpleDeclaration(unsigned Context,
                                         SourceLocation &DeclEnd,
-                                        AttributeList *Attr);
+                                        AttributeList *Attr,
+                                        bool RequireSemi);
   DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context,
                                 bool AllowFunctionDefinitions,
                                 SourceLocation *DeclEnd = 0);

Modified: vendor/clang/dist/lib/AST/ASTImporter.cpp
==============================================================================
--- vendor/clang/dist/lib/AST/ASTImporter.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/AST/ASTImporter.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -3088,8 +3088,7 @@ FileID ASTImporter::Import(FileID FromID
     // FIXME: We want to re-use the existing MemoryBuffer!
     const llvm::MemoryBuffer *FromBuf = Cache->getBuffer(getDiags());
     llvm::MemoryBuffer *ToBuf
-      = llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBufferStart(),
-                                             FromBuf->getBufferEnd(),
+      = llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
                                              FromBuf->getBufferIdentifier());
     ToID = ToSM.createFileIDForMemBuffer(ToBuf);
   }

Modified: vendor/clang/dist/lib/AST/Stmt.cpp
==============================================================================
--- vendor/clang/dist/lib/AST/Stmt.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/AST/Stmt.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -249,14 +249,18 @@ unsigned AsmStmt::AnalyzeAsmString(llvm:
     }
 
     char CurChar = *CurPtr++;
-    if (CurChar == '$') {
-      CurStringPiece += "$$";
-      continue;
-    } else if (CurChar != '%') {
+    switch (CurChar) {
+    case '$': CurStringPiece += "$$"; continue;
+    case '{': CurStringPiece += "$("; continue;
+    case '|': CurStringPiece += "$|"; continue;
+    case '}': CurStringPiece += "$)"; continue;
+    case '%':
+      break;
+    default:
       CurStringPiece += CurChar;
       continue;
     }
-
+    
     // Escaped "%" character in asm string.
     if (CurPtr == StrEnd) {
       // % at end of string is invalid (no escape).

Modified: vendor/clang/dist/lib/AST/TypePrinter.cpp
==============================================================================
--- vendor/clang/dist/lib/AST/TypePrinter.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/AST/TypePrinter.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -442,18 +442,21 @@ void TypePrinter::PrintTag(TagDecl *D, s
     llvm::raw_string_ostream OS(Buffer);
     OS << "<anonymous";
 
-    // Suppress the redundant tag keyword if we just printed one.
-    // We don't have to worry about ElaboratedTypes here because you can't
-    // refer to an anonymous type with one.
-    if (!HasKindDecoration)
-      OS << " " << D->getKindName();
-
-    PresumedLoc PLoc = D->getASTContext().getSourceManager().getPresumedLoc(
-      D->getLocation());
-    OS << " at " << PLoc.getFilename()
-       << ':' << PLoc.getLine()
-       << ':' << PLoc.getColumn()
-       << '>';
+    if (Policy.AnonymousTagLocations) {
+      // Suppress the redundant tag keyword if we just printed one.
+      // We don't have to worry about ElaboratedTypes here because you can't
+      // refer to an anonymous type with one.
+      if (!HasKindDecoration)
+        OS << " " << D->getKindName();
+
+      PresumedLoc PLoc = D->getASTContext().getSourceManager().getPresumedLoc(
+        D->getLocation());
+      OS << " at " << PLoc.getFilename()
+         << ':' << PLoc.getLine()
+         << ':' << PLoc.getColumn();
+    }
+    
+    OS << '>';
     OS.flush();
   }
 

Modified: vendor/clang/dist/lib/Checker/BugReporter.cpp
==============================================================================
--- vendor/clang/dist/lib/Checker/BugReporter.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/Checker/BugReporter.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -58,7 +58,7 @@ void BugReporterContext::addVisitor(BugR
 // Helper routines for walking the ExplodedGraph and fetching statements.
 //===----------------------------------------------------------------------===//
 
-static inline const Stmt* GetStmt(ProgramPoint P) {
+static inline const Stmt* GetStmt(const ProgramPoint &P) {
   if (const StmtPoint* SP = dyn_cast<StmtPoint>(&P))
     return SP->getStmt();
   else if (const BlockEdge* BE = dyn_cast<BlockEdge>(&P))

Modified: vendor/clang/dist/lib/Checker/Environment.cpp
==============================================================================
--- vendor/clang/dist/lib/Checker/Environment.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/Checker/Environment.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -96,6 +96,19 @@ public:
 };
 } // end anonymous namespace
 
+static bool isBlockExprInCallers(const Stmt *E, const LocationContext *LC) {
+  const LocationContext *ParentLC = LC->getParent();
+  while (ParentLC) {
+    CFG &C = *ParentLC->getCFG();
+    if (C.isBlkExpr(E))
+      return true;
+    ParentLC = ParentLC->getParent();
+  }
+
+  return false;
+}
+
+
 // RemoveDeadBindings:
 //  - Remove subexpression bindings.
 //  - Remove dead block expression bindings.
@@ -122,13 +135,27 @@ EnvironmentManager::RemoveDeadBindings(E
        I != E; ++I) {
 
     const Stmt *BlkExpr = I.getKey();
+    const SVal &X = I.getData();
+
+    // Block-level expressions in callers are assumed always live.
+    if (isBlockExprInCallers(BlkExpr, SymReaper.getLocationContext())) {
+      NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X);
+
+      if (isa<loc::MemRegionVal>(X)) {
+        const MemRegion* R = cast<loc::MemRegionVal>(X).getRegion();
+        DRoots.push_back(R);
+      }
+
+      // Mark all symbols in the block expr's value live.
+      MarkLiveCallback cb(SymReaper);
+      ST->scanReachableSymbols(X, cb);
+      continue;
+    }
 
     // Not a block-level expression?
     if (!C.isBlkExpr(BlkExpr))
       continue;
 
-    const SVal &X = I.getData();
-
     if (SymReaper.isLive(S, BlkExpr)) {
       // Copy the binding to the new map.
       NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X);
@@ -137,14 +164,6 @@ EnvironmentManager::RemoveDeadBindings(E
       if (isa<loc::MemRegionVal>(X)) {
         const MemRegion* R = cast<loc::MemRegionVal>(X).getRegion();
         DRoots.push_back(R);
-        // Mark the super region of the RX as live.
-        // e.g.: int x; char *y = (char*) &x; if (*y) ...
-        // 'y' => element region. 'x' is its super region.
-        // We only add one level super region for now.
-
-        // FIXME: maybe multiple level of super regions should be added.
-        if (const SubRegion *SR = dyn_cast<SubRegion>(R))
-          DRoots.push_back(SR->getSuperRegion());
       }
 
       // Mark all symbols in the block expr's value live.

Modified: vendor/clang/dist/lib/CodeGen/CGBuiltin.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGBuiltin.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGBuiltin.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -338,38 +338,50 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BIbzero:
   case Builtin::BI__builtin_bzero: {
     Value *Address = EmitScalarExpr(E->getArg(0));
-    Builder.CreateCall4(CGM.getMemSetFn(), Address,
-                        llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), 0),
-                        EmitScalarExpr(E->getArg(1)),
-                        llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
+    Value *SizeVal = EmitScalarExpr(E->getArg(1));
+    Builder.CreateCall5(CGM.getMemSetFn(Address->getType(), SizeVal->getType()),
+                   Address,
+                   llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), 0),
+                   SizeVal,
+                   llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1),
+                   llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), 0));
     return RValue::get(Address);
   }
   case Builtin::BImemcpy:
   case Builtin::BI__builtin_memcpy: {
     Value *Address = EmitScalarExpr(E->getArg(0));
-    Builder.CreateCall4(CGM.getMemCpyFn(), Address,
-                        EmitScalarExpr(E->getArg(1)),
-                        EmitScalarExpr(E->getArg(2)),
-                        llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
+    Value *SrcAddr = EmitScalarExpr(E->getArg(1));
+    Value *SizeVal = EmitScalarExpr(E->getArg(2));
+    Builder.CreateCall5(CGM.getMemCpyFn(Address->getType(), SrcAddr->getType(),
+                                        SizeVal->getType()),
+                  Address, SrcAddr, SizeVal, 
+                  llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1),
+                  llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), 0));
     return RValue::get(Address);
   }
   case Builtin::BImemmove:
   case Builtin::BI__builtin_memmove: {
     Value *Address = EmitScalarExpr(E->getArg(0));
-    Builder.CreateCall4(CGM.getMemMoveFn(), Address,
-                        EmitScalarExpr(E->getArg(1)),
-                        EmitScalarExpr(E->getArg(2)),
-                        llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
+    Value *SrcAddr = EmitScalarExpr(E->getArg(1));
+    Value *SizeVal = EmitScalarExpr(E->getArg(2));
+    Builder.CreateCall5(CGM.getMemMoveFn(Address->getType(), SrcAddr->getType(),
+                                         SizeVal->getType()),
+                  Address, SrcAddr, SizeVal, 
+                  llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1),
+                  llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), 0));
     return RValue::get(Address);
   }
   case Builtin::BImemset:
   case Builtin::BI__builtin_memset: {
     Value *Address = EmitScalarExpr(E->getArg(0));
-    Builder.CreateCall4(CGM.getMemSetFn(), Address,
-                        Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)),
-                                            llvm::Type::getInt8Ty(VMContext)),
-                        EmitScalarExpr(E->getArg(2)),
-                        llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
+    Value *SizeVal = EmitScalarExpr(E->getArg(2));
+    Builder.CreateCall5(CGM.getMemSetFn(Address->getType(), SizeVal->getType()),
+                  Address,
+                  Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)),
+                                      llvm::Type::getInt8Ty(VMContext)),
+                  SizeVal,
+                  llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1),
+                  llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), 0));
     return RValue::get(Address);
   }
   case Builtin::BI__builtin_dwarf_cfa: {

Modified: vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -1380,7 +1380,9 @@ void CGDebugInfo::EmitStopPoint(llvm::Fu
        || (SM.getInstantiationLineNumber(CurLoc) ==
            SM.getInstantiationLineNumber(PrevLoc)
            && SM.isFromSameFile(CurLoc, PrevLoc)))
-    return;
+    // New Builder may not be in sync with CGDebugInfo.
+    if (!Builder.getCurrentDebugLocation().isUnknown())
+      return;
 
   // Update last state.
   PrevLoc = CurLoc;

Modified: vendor/clang/dist/lib/CodeGen/CGDecl.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGDecl.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGDecl.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -564,11 +564,15 @@ void CodeGenFunction::EmitLocalBlockVarD
       if (Loc->getType() != BP)
         Loc = Builder.CreateBitCast(Loc, BP, "tmp");
       
+      llvm::Value *NotVolatile =
+        llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), 0);
+
       // If the initializer is all zeros, codegen with memset.
       if (isa<llvm::ConstantAggregateZero>(Init)) {
         llvm::Value *Zero =
-        llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), 0);
-        Builder.CreateCall4(CGM.getMemSetFn(), Loc, Zero, SizeVal, AlignVal);
+          llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), 0);
+        Builder.CreateCall5(CGM.getMemSetFn(Loc->getType(), SizeVal->getType()),
+                            Loc, Zero, SizeVal, AlignVal, NotVolatile);
       } else {
         // Otherwise, create a temporary global with the initializer then 
         // memcpy from the global to the alloca.
@@ -582,8 +586,10 @@ void CodeGenFunction::EmitLocalBlockVarD
         llvm::Value *SrcPtr = GV;
         if (SrcPtr->getType() != BP)
           SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
-        
-        Builder.CreateCall4(CGM.getMemCpyFn(), Loc, SrcPtr, SizeVal, AlignVal);
+
+        Builder.CreateCall5(CGM.getMemCpyFn(Loc->getType(), SrcPtr->getType(),
+                                            SizeVal->getType()),
+                            Loc, SrcPtr, SizeVal, AlignVal, NotVolatile);
       }
     } else if (Ty->isReferenceType()) {
       RValue RV = EmitReferenceBindingToExpr(Init, /*IsInitializer=*/true);

Modified: vendor/clang/dist/lib/CodeGen/CGExpr.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGExpr.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGExpr.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -345,7 +345,7 @@ EmitScalarPrePostIncDec(const UnaryOpera
   }
   
   // Store the updated result through the lvalue.
-  if (LV.isBitfield())
+  if (LV.isBitField())
     EmitStoreThroughBitfieldLValue(RValue::get(NextVal), LV, ValTy, &NextVal);
   else
     EmitStoreThroughLValue(RValue::get(NextVal), LV, ValTy);
@@ -429,7 +429,7 @@ LValue CodeGenFunction::EmitUnsupportedL
 
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E) {
   LValue LV = EmitLValue(E);
-  if (!isa<DeclRefExpr>(E) && !LV.isBitfield() && LV.isSimple())
+  if (!isa<DeclRefExpr>(E) && !LV.isBitField() && LV.isSimple())
     EmitCheck(LV.getAddress(), getContext().getTypeSize(E->getType()) / 8);
   return LV;
 }
@@ -593,7 +593,7 @@ RValue CodeGenFunction::EmitLoadOfLValue
   if (LV.isExtVectorElt())
     return EmitLoadOfExtVectorElementLValue(LV, ExprType);
 
-  if (LV.isBitfield())
+  if (LV.isBitField())
     return EmitLoadOfBitfieldLValue(LV, ExprType);
 
   if (LV.isPropertyRef())
@@ -605,9 +605,10 @@ RValue CodeGenFunction::EmitLoadOfLValue
 
 RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
                                                  QualType ExprType) {
-  unsigned StartBit = LV.getBitfieldStartBit();
-  unsigned BitfieldSize = LV.getBitfieldSize();
-  llvm::Value *Ptr = LV.getBitfieldAddr();
+  const CGBitFieldInfo &Info = LV.getBitFieldInfo();
+  unsigned StartBit = Info.Start;
+  unsigned BitfieldSize = Info.Size;
+  llvm::Value *Ptr = LV.getBitFieldAddr();
 
   const llvm::Type *EltTy =
     cast<llvm::PointerType>(Ptr->getType())->getElementType();
@@ -650,7 +651,7 @@ RValue CodeGenFunction::EmitLoadOfBitfie
   }
 
   // Sign extend if necessary.
-  if (LV.isBitfieldSigned()) {
+  if (Info.IsSigned) {
     llvm::Value *ExtraBits = llvm::ConstantInt::get(EltTy,
                                                     EltTySize - BitfieldSize);
     Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits),
@@ -733,7 +734,7 @@ void CodeGenFunction::EmitStoreThroughLV
     if (Dst.isExtVectorElt())
       return EmitStoreThroughExtVectorComponentLValue(Src, Dst, Ty);
 
-    if (Dst.isBitfield())
+    if (Dst.isBitField())
       return EmitStoreThroughBitfieldLValue(Src, Dst, Ty);
 
     if (Dst.isPropertyRef())
@@ -781,9 +782,10 @@ void CodeGenFunction::EmitStoreThroughLV
 void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
                                                      QualType Ty,
                                                      llvm::Value **Result) {
-  unsigned StartBit = Dst.getBitfieldStartBit();
-  unsigned BitfieldSize = Dst.getBitfieldSize();
-  llvm::Value *Ptr = Dst.getBitfieldAddr();
+  const CGBitFieldInfo &Info = Dst.getBitFieldInfo();
+  unsigned StartBit = Info.Start;
+  unsigned BitfieldSize = Info.Size;
+  llvm::Value *Ptr = Dst.getBitFieldAddr();
 
   const llvm::Type *EltTy =
     cast<llvm::PointerType>(Ptr->getType())->getElementType();
@@ -805,7 +807,7 @@ void CodeGenFunction::EmitStoreThroughBi
                                                   "bf.reload.val");
 
     // Sign extend if necessary.
-    if (Dst.isBitfieldSigned()) {
+    if (Info.IsSigned) {
       unsigned SrcTySize = CGM.getTargetData().getTypeSizeInBits(SrcTy);
       llvm::Value *ExtraBits = llvm::ConstantInt::get(SrcTy,
                                                       SrcTySize - BitfieldSize);
@@ -1471,7 +1473,7 @@ LValue CodeGenFunction::EmitLValueForBit
                                               unsigned CVRQualifiers) {
   const CGRecordLayout &RL =
     CGM.getTypes().getCGRecordLayout(Field->getParent());
-  const CGRecordLayout::BitFieldInfo &Info = RL.getBitFieldInfo(Field);
+  const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
 
   // FIXME: CodeGenTypes should expose a method to get the appropriate type for
   // FieldTy (the appropriate type is ABI-dependent).
@@ -1481,16 +1483,11 @@ LValue CodeGenFunction::EmitLValueForBit
   cast<llvm::PointerType>(BaseValue->getType());
   unsigned AS = BaseTy->getAddressSpace();
   BaseValue = Builder.CreateBitCast(BaseValue,
-                                    llvm::PointerType::get(FieldTy, AS),
-                                    "tmp");
+                                    llvm::PointerType::get(FieldTy, AS));
+  llvm::Value *V = Builder.CreateConstGEP1_32(BaseValue, Info.FieldNo);
 
-  llvm::Value *Idx =
-    llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), Info.FieldNo);
-  llvm::Value *V = Builder.CreateGEP(BaseValue, Idx, "tmp");
-
-  return LValue::MakeBitfield(V, Info.Start, Info.Size,
-                              Field->getType()->isSignedIntegerType(),
-                            Field->getType().getCVRQualifiers()|CVRQualifiers);
+  return LValue::MakeBitfield(V, Info,
+                             Field->getType().getCVRQualifiers()|CVRQualifiers);
 }
 
 LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,

Modified: vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -771,12 +771,27 @@ void CodeGenFunction::EmitAggregateCopy(
   //   a = b;
   // }
   //
-  // we need to use a differnt call here.  We use isVolatile to indicate when
+  // we need to use a different call here.  We use isVolatile to indicate when
   // either the source or the destination is volatile.
-  Builder.CreateCall4(CGM.getMemCpyFn(),
+  const llvm::Type *I1Ty = llvm::Type::getInt1Ty(VMContext);
+  const llvm::Type *I8Ty = llvm::Type::getInt8Ty(VMContext);
+  const llvm::Type *I32Ty = llvm::Type::getInt32Ty(VMContext);
+
+  const llvm::PointerType *DPT = cast<llvm::PointerType>(DestPtr->getType());
+  const llvm::Type *DBP = llvm::PointerType::get(I8Ty, DPT->getAddressSpace());
+  if (DestPtr->getType() != DBP)
+    DestPtr = Builder.CreateBitCast(DestPtr, DBP, "tmp");
+
+  const llvm::PointerType *SPT = cast<llvm::PointerType>(SrcPtr->getType());
+  const llvm::Type *SBP = llvm::PointerType::get(I8Ty, SPT->getAddressSpace());
+  if (SrcPtr->getType() != SBP)
+    SrcPtr = Builder.CreateBitCast(SrcPtr, SBP, "tmp");
+
+  Builder.CreateCall5(CGM.getMemCpyFn(DestPtr->getType(), SrcPtr->getType(),
+                                      IntPtr),
                       DestPtr, SrcPtr,
                       // TypeInfo.first describes size in bits.
                       llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
-                      llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
-                                             TypeInfo.second/8));
+                      llvm::ConstantInt::get(I32Ty,  TypeInfo.second/8),
+                      llvm::ConstantInt::get(I1Ty,  isVolatile));
 }

Modified: vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -1140,7 +1140,7 @@ Value *ScalarExprEmitter::EmitCompoundAs
   // specially because the result is altered by the store, i.e., [C99 6.5.16p1]
   // 'An assignment expression has the value of the left operand after the
   // assignment...'.
-  if (LHSLV.isBitfield()) {
+  if (LHSLV.isBitField()) {
     if (!LHSLV.isVolatileQualified()) {
       CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, LHSTy,
                                          &Result);
@@ -1575,7 +1575,7 @@ Value *ScalarExprEmitter::VisitBinAssign
   // because the result is altered by the store, i.e., [C99 6.5.16p1]
   // 'An assignment expression has the value of the left operand after
   // the assignment...'.
-  if (LHS.isBitfield()) {
+  if (LHS.isBitField()) {
     if (!LHS.isVolatileQualified()) {
       CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, E->getType(),
                                          &RHS);

Modified: vendor/clang/dist/lib/CodeGen/CGObjC.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGObjC.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGObjC.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -108,6 +108,10 @@ RValue CodeGenFunction::EmitObjCMessageE
 void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
                                       const ObjCContainerDecl *CD) {
   FunctionArgList Args;
+  // Check if we should generate debug info for this method.
+  if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
+    DebugInfo = CGM.getDebugInfo();
+
   llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
 
   const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(OMD);
@@ -128,9 +132,6 @@ void CodeGenFunction::StartObjCMethod(co
 /// Generate an Objective-C method.  An Objective-C method is a C function with
 /// its pointer, name, and types registered in the class struture.
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
-  // Check if we should generate debug info for this method.
-  if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
-    DebugInfo = CGM.getDebugInfo();
   StartObjCMethod(OMD, OMD->getClassInterface());
   EmitStmt(OMD->getBody());
   FinishFunction(OMD->getBodyRBrace());

Modified: vendor/clang/dist/lib/CodeGen/CGObjCMac.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGObjCMac.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGObjCMac.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -107,24 +107,31 @@ LValue CGObjCRuntime::EmitValueForIvarAt
   Qualifiers Quals = CGF.MakeQualifiers(IvarTy);
   Quals.addCVRQualifiers(CVRQualifiers);
 
-  if (Ivar->isBitField()) {
-    // We need to compute the bit offset for the bit-field, the offset
-    // is to the byte. Note, there is a subtle invariant here: we can
-    // only call this routine on non-sythesized ivars but we may be
-    // called for synthesized ivars. However, a synthesized ivar can
-    // never be a bit-field so this is safe.
-    uint64_t BitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar) % 8;
+  if (!Ivar->isBitField())
+    return LValue::MakeAddr(V, Quals);
 
-    uint64_t BitFieldSize =
-      Ivar->getBitWidth()->EvaluateAsInt(CGF.getContext()).getZExtValue();
-    return LValue::MakeBitfield(V, BitOffset, BitFieldSize,
-                                IvarTy->isSignedIntegerType(),
-                                Quals.getCVRQualifiers());
-  }
+  // We need to compute the bit offset for the bit-field, the offset is to the
+  // byte. Note, there is a subtle invariant here: we can only call this routine
+  // on non-synthesized ivars but we may be called for synthesized ivars.
+  // However, a synthesized ivar can never be a bit-field, so this is safe.
+  uint64_t BitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar) % 8;
+  uint64_t BitFieldSize =
+    Ivar->getBitWidth()->EvaluateAsInt(CGF.getContext()).getZExtValue();
 
-  
-  LValue LV = LValue::MakeAddr(V, Quals);
-  return LV;
+  // Allocate a new CGBitFieldInfo object to describe this access.
+  //
+  // FIXME: This is incredibly wasteful, these should be uniqued or part of some
+  // layout object. However, this is blocked on other cleanups to the
+  // Objective-C code, so for now we just live with allocating a bunch of these
+  // objects.
+  unsigned FieldNo = 0; // This value is unused.
+  CGBitFieldInfo *Info =
+    new (CGF.CGM.getContext()) CGBitFieldInfo(FieldNo, BitOffset, BitFieldSize,
+                                              IvarTy->isSignedIntegerType());
+
+  // FIXME: We need to set a very conservative alignment on this, or make sure
+  // that the runtime is doing the right thing.
+  return LValue::MakeBitfield(V, *Info, Quals.getCVRQualifiers());
 }
 
 ///
@@ -3128,7 +3135,7 @@ void CGObjCCommonMac::BuildAggrIvarLayou
       const CGRecordLayout &RL =
         CGM.getTypes().getCGRecordLayout(Field->getParent());
       if (Field->isBitField()) {
-        const CGRecordLayout::BitFieldInfo &Info = RL.getBitFieldInfo(Field);
+        const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
 
         const llvm::Type *Ty =
           CGM.getTypes().ConvertTypeForMemRecursive(Field->getType());

Modified: vendor/clang/dist/lib/CodeGen/CGObjCRuntime.h
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGObjCRuntime.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGObjCRuntime.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -61,12 +61,11 @@ namespace CodeGen {
 
 /// Implements runtime-specific code generation functions.
 class CGObjCRuntime {
-public:
+protected:
   // Utility functions for unified ivar access. These need to
   // eventually be folded into other places (the structure layout
   // code).
 
-protected:
   /// Compute an offset to the given ivar, suitable for passing to
   /// EmitValueForIvarAtOffset.  Note that the correct handling of
   /// bit-fields is carefully coordinated by these two, use caution!

Modified: vendor/clang/dist/lib/CodeGen/CGRecordLayout.h
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGRecordLayout.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGRecordLayout.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -19,6 +19,18 @@ namespace llvm {
 namespace clang {
 namespace CodeGen {
 
+class CGBitFieldInfo {
+public:
+  CGBitFieldInfo(unsigned FieldNo, unsigned Start, unsigned Size,
+                 bool IsSigned)
+    : FieldNo(FieldNo), Start(Start), Size(Size), IsSigned(IsSigned) {}
+
+  unsigned FieldNo;
+  unsigned Start;
+  unsigned Size;
+  bool IsSigned : 1;
+};
+
 /// CGRecordLayout - This class handles struct and union layout info while
 /// lowering AST types to LLVM types.
 ///
@@ -29,18 +41,6 @@ class CGRecordLayout {
   CGRecordLayout(const CGRecordLayout&); // DO NOT IMPLEMENT
   void operator=(const CGRecordLayout&); // DO NOT IMPLEMENT
 
-public:
-  struct BitFieldInfo {
-    BitFieldInfo(unsigned FieldNo,
-                 unsigned Start,
-                 unsigned Size)
-      : FieldNo(FieldNo), Start(Start), Size(Size) {}
-
-    unsigned FieldNo;
-    unsigned Start;
-    unsigned Size;
-  };
-
 private:
   /// The LLVMType corresponding to this record layout.
   const llvm::Type *LLVMType;
@@ -51,7 +51,7 @@ private:
 
   /// Map from (bit-field) struct field to the corresponding llvm struct type
   /// field no. This info is populated by record builder.
-  llvm::DenseMap<const FieldDecl *, BitFieldInfo> BitFields;
+  llvm::DenseMap<const FieldDecl *, CGBitFieldInfo> BitFields;
 
   /// Whether one of the fields in this record layout is a pointer to data
   /// member, or a struct that contains pointer to data member.
@@ -80,9 +80,9 @@ public:
 
   /// \brief Return llvm::StructType element number that corresponds to the
   /// field FD.
-  const BitFieldInfo &getBitFieldInfo(const FieldDecl *FD) const {
+  const CGBitFieldInfo &getBitFieldInfo(const FieldDecl *FD) const {
     assert(FD->isBitField() && "Invalid call for non bit-field decl!");
-    llvm::DenseMap<const FieldDecl *, BitFieldInfo>::const_iterator
+    llvm::DenseMap<const FieldDecl *, CGBitFieldInfo>::const_iterator
       it = BitFields.find(FD);
     assert(it != BitFields.end()  && "Unable to find bitfield info");
     return it->second;

Modified: vendor/clang/dist/lib/CodeGen/CGRecordLayoutBuilder.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGRecordLayoutBuilder.cpp	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGRecordLayoutBuilder.cpp	Tue Apr  6 15:53:59 2010	(r206275)
@@ -37,17 +37,7 @@ public:
   llvm::SmallVector<LLVMFieldInfo, 16> LLVMFields;
 
   /// LLVMBitFieldInfo - Holds location and size information about a bit field.
-  struct LLVMBitFieldInfo {
-    LLVMBitFieldInfo(const FieldDecl *FD, unsigned FieldNo, unsigned Start,
-                     unsigned Size)
-      : FD(FD), FieldNo(FieldNo), Start(Start), Size(Size) { }
-
-    const FieldDecl *FD;
-
-    unsigned FieldNo;
-    unsigned Start;
-    unsigned Size;
-  };
+  typedef std::pair<const FieldDecl *, CGBitFieldInfo> LLVMBitFieldInfo;
   llvm::SmallVector<LLVMBitFieldInfo, 16> LLVMBitFields;
 
   /// ContainsPointerToDataMember - Whether one of the fields in this record
@@ -188,9 +178,11 @@ void CGRecordLayoutBuilder::LayoutBitFie
   const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType());
   uint64_t TypeSizeInBits = getTypeSizeInBytes(Ty) * 8;
 
-  LLVMBitFields.push_back(LLVMBitFieldInfo(D, FieldOffset / TypeSizeInBits,
-                                           FieldOffset % TypeSizeInBits,
-                                           FieldSize));
+  bool IsSigned = D->getType()->isSignedIntegerType();
+  LLVMBitFields.push_back(LLVMBitFieldInfo(
+                            D, CGBitFieldInfo(FieldOffset / TypeSizeInBits,
+                                              FieldOffset % TypeSizeInBits,
+                                              FieldSize, IsSigned)));
 
   AppendBytes(NumBytesToAppend);
 
@@ -288,7 +280,10 @@ void CGRecordLayoutBuilder::LayoutUnion(
         continue;
 
       // Add the bit field info.
-      LLVMBitFields.push_back(LLVMBitFieldInfo(*Field, 0, 0, FieldSize));
+      bool IsSigned = Field->getType()->isSignedIntegerType();
+      LLVMBitFields.push_back(LLVMBitFieldInfo(
+                                *Field, CGBitFieldInfo(0, 0, FieldSize,
+                                                       IsSigned)));
     } else {
       LLVMFields.push_back(LLVMFieldInfo(*Field, 0));
     }
@@ -494,21 +489,12 @@ CGRecordLayout *CodeGenTypes::ComputeRec
     new CGRecordLayout(Ty, Builder.ContainsPointerToDataMember);
 
   // Add all the field numbers.
-  for (unsigned i = 0, e = Builder.LLVMFields.size(); i != e; ++i) {
-    const FieldDecl *FD = Builder.LLVMFields[i].first;
-    unsigned FieldNo = Builder.LLVMFields[i].second;
-
-    RL->FieldInfo.insert(std::make_pair(FD, FieldNo));
-  }
+  for (unsigned i = 0, e = Builder.LLVMFields.size(); i != e; ++i)
+    RL->FieldInfo.insert(Builder.LLVMFields[i]);
 
   // Add bitfield info.
-  for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i) {
-    const CGRecordLayoutBuilder::LLVMBitFieldInfo &Info =
-      Builder.LLVMBitFields[i];
-
-    CGRecordLayout::BitFieldInfo BFI(Info.FieldNo, Info.Start, Info.Size);
-    RL->BitFields.insert(std::make_pair(Info.FD, BFI));
-  }
+  for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i)
+    RL->BitFields.insert(Builder.LLVMBitFields[i]);
 
   return RL;
 }

Modified: vendor/clang/dist/lib/CodeGen/CGValue.h
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CGValue.h	Tue Apr  6 15:52:58 2010	(r206274)
+++ vendor/clang/dist/lib/CodeGen/CGValue.h	Tue Apr  6 15:53:59 2010	(r206275)
@@ -27,6 +27,7 @@ namespace clang {
   class ObjCImplicitSetterGetterRefExpr;
 
 namespace CodeGen {
+  class CGBitFieldInfo;
 
 /// RValue - This trivial value class is used to represent the result of an
 /// expression that is evaluated.  It can be one of three things: either a
@@ -128,14 +129,11 @@ class LValue {
     llvm::Constant *VectorElts;
 
     // BitField start bit and size
-    struct {
-      unsigned short StartBit;
-      unsigned short Size;
-      bool IsSigned;
-    } BitfieldData;
+    const CGBitFieldInfo *BitFieldInfo;
 
     // Obj-C property reference expression
     const ObjCPropertyRefExpr *PropertyRefExpr;
+
     // ObjC 'implicit' property reference expression
     const ObjCImplicitSetterGetterRefExpr *KVCRefExpr;
   };
@@ -170,7 +168,7 @@ private:
 public:
   bool isSimple() const { return LVType == Simple; }
   bool isVectorElt() const { return LVType == VectorElt; }
-  bool isBitfield() const { return LVType == BitField; }
+  bool isBitField() const { return LVType == BitField; }
   bool isExtVectorElt() const { return LVType == ExtVectorElt; }
   bool isPropertyRef() const { return LVType == PropertyRef; }
   bool isKVCRef() const { return LVType == KVCRef; }
@@ -209,29 +207,28 @@ public:
 
   // simple lvalue
   llvm::Value *getAddress() const { assert(isSimple()); return V; }
+
   // vector elt lvalue
   llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
   llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
+
   // extended vector elements.
   llvm::Value *getExtVectorAddr() const { assert(isExtVectorElt()); return V; }
   llvm::Constant *getExtVectorElts() const {
     assert(isExtVectorElt());
     return VectorElts;
   }
+
   // bitfield lvalue
-  llvm::Value *getBitfieldAddr() const { assert(isBitfield()); return V; }
-  unsigned short getBitfieldStartBit() const {
-    assert(isBitfield());
-    return BitfieldData.StartBit;
-  }
-  unsigned short getBitfieldSize() const {
-    assert(isBitfield());
-    return BitfieldData.Size;
-  }
-  bool isBitfieldSigned() const {
-    assert(isBitfield());
-    return BitfieldData.IsSigned;
+  llvm::Value *getBitFieldAddr() const {
+    assert(isBitField());
+    return V;
+  }
+  const CGBitFieldInfo &getBitFieldInfo() const {
+    assert(isBitField());
+    return *BitFieldInfo;
   }
+
   // property ref lvalue
   const ObjCPropertyRefExpr *getPropertyRefExpr() const {
     assert(isPropertyRef());
@@ -272,15 +269,12 @@ public:
     return R;
   }
 
-  static LValue MakeBitfield(llvm::Value *V, unsigned short StartBit,
-                             unsigned short Size, bool IsSigned,
+  static LValue MakeBitfield(llvm::Value *V, const CGBitFieldInfo &Info,
                              unsigned CVR) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-vendor mailing list