diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-17 21:46:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-17 21:46:47 +0000 |
commit | ba6e55737825046a5e1dff82d54a0745f11c0796 (patch) | |
tree | 455f2ded98fa44f294bbfedbf02435128b678b69 /clang | |
parent | 12f0dea9221065a44bdb96a9e1b3eb220b5fcde0 (diff) | |
download | bcm5719-llvm-ba6e55737825046a5e1dff82d54a0745f11c0796.tar.gz bcm5719-llvm-ba6e55737825046a5e1dff82d54a0745f11c0796.zip |
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.
llvm-svn: 69390
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/DeclContextInternals.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | clang/test/PCH/multiple_decls.c | 17 | ||||
-rw-r--r-- | clang/test/PCH/multiple_decls.h | 7 |
4 files changed, 26 insertions, 2 deletions
diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h index 6a905be4a7e..6c1231c0a73 100644 --- a/clang/include/clang/AST/DeclContextInternals.h +++ b/clang/include/clang/AST/DeclContextInternals.h @@ -101,7 +101,7 @@ public: 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()); diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 83efc75baef..523615491d5 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -222,7 +222,7 @@ void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) { 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; } diff --git a/clang/test/PCH/multiple_decls.c b/clang/test/PCH/multiple_decls.c new file mode 100644 index 00000000000..f73567ed01d --- /dev/null +++ b/clang/test/PCH/multiple_decls.c @@ -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); +} diff --git a/clang/test/PCH/multiple_decls.h b/clang/test/PCH/multiple_decls.h new file mode 100644 index 00000000000..23696b0470d --- /dev/null +++ b/clang/test/PCH/multiple_decls.h @@ -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); |