[cfe-commits] r69390 - in /cfe/trunk: include/clang/AST/DeclContextInternals.h lib/AST/Expr.cpp test/PCH/multiple_decls.c test/PCH/multiple_decls.h

Douglas Gregor dgregor at apple.com
Fri Apr 17 14:46:47 PDT 2009


Author: dgregor
Date: Fri Apr 17 16:46:47 2009
New Revision: 69390

URL: http://llvm.org/viewvc/llvm-project?rev=69390&view=rev
Log:
Fix two embarrassing PCH bugs:
  1) Accidentally used delete [] on an array of statements that was allocated with ASTContext's allocator
  2) Deserialization of names with multiple declarations (e.g., a struct and a function) used the wrong mangling constant, causing it to view declaration IDs as Decl*s.

403.gcc builds and links properly.


Added:
    cfe/trunk/test/PCH/multiple_decls.c
    cfe/trunk/test/PCH/multiple_decls.h
Modified:
    cfe/trunk/include/clang/AST/DeclContextInternals.h
    cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/DeclContextInternals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclContextInternals.h?rev=69390&r1=69389&r2=69390&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclContextInternals.h (original)
+++ cfe/trunk/include/clang/AST/DeclContextInternals.h Fri Apr 17 16:46:47 2009
@@ -101,7 +101,7 @@
       VectorTy *Vector = getAsVector();
       if (!Vector) {
         Vector = new VectorTy;
-        Data = reinterpret_cast<uintptr_t>(Vector) | DK_Decl_Vector;
+        Data = reinterpret_cast<uintptr_t>(Vector) | DK_ID_Vector;
       }
 
       Vector->resize(Vec.size());

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=69390&r1=69389&r2=69390&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Apr 17 16:46:47 2009
@@ -222,7 +222,7 @@
   for (unsigned i = getNumArgs()+ARGS_START; i != NumArgs+ARGS_START; ++i)
     NewSubExprs[i] = 0;
   
-  delete [] SubExprs;
+  if (SubExprs) C.Deallocate(SubExprs);
   SubExprs = NewSubExprs;
   this->NumArgs = NumArgs;
 }

Added: cfe/trunk/test/PCH/multiple_decls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/multiple_decls.c?rev=69390&view=auto

==============================================================================
--- cfe/trunk/test/PCH/multiple_decls.c (added)
+++ cfe/trunk/test/PCH/multiple_decls.c Fri Apr 17 16:46:47 2009
@@ -0,0 +1,17 @@
+// Test this without pch.
+// RUN: clang-cc -include %S/multiple_decls.h -fsyntax-only -ast-print -o - %s
+
+// Test with pch.
+// RUN: clang-cc -emit-pch -o %t %S/multiple_decls.h &&
+// RUN: clang-cc -include-pch %t -fsyntax-only -ast-print -o - %s 
+
+void f0(char c) {
+  wide(c);
+}
+
+struct wide w;
+struct narrow n;
+
+void f1(int i) {
+  narrow(i);
+}

Added: cfe/trunk/test/PCH/multiple_decls.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/multiple_decls.h?rev=69390&view=auto

==============================================================================
--- cfe/trunk/test/PCH/multiple_decls.h (added)
+++ cfe/trunk/test/PCH/multiple_decls.h Fri Apr 17 16:46:47 2009
@@ -0,0 +1,7 @@
+// Header for PCH test multiple_decls.c
+
+struct wide { int value; };
+int wide(char);
+
+struct narrow { char narrow; };
+char narrow(int);





More information about the cfe-commits mailing list