From ba266eec79a9293910a5875d31cc0813bbc8a233 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Tue, 19 Oct 2010 21:54:32 +0000 Subject: [PATCH] Putting back safe fixes 116836,116837,116838 llvm-svn: 116866 --- clang/lib/AST/Decl.cpp | 2 + clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/test/PCH/Inputs/chain-cxx1.h | 19 ------ clang/test/PCH/Inputs/chain-cxx2.h | 32 ---------- clang/test/PCH/chain-cxx.cpp | 73 ++++++++++++++++++++++- 5 files changed, 73 insertions(+), 55 deletions(-) delete mode 100644 clang/test/PCH/Inputs/chain-cxx1.h delete mode 100644 clang/test/PCH/Inputs/chain-cxx2.h diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index e822009c5802..4898d6f2fc0c 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1580,6 +1580,8 @@ void TagDecl::completeDefinition() { TagDecl* TagDecl::getDefinition() const { if (isDefinition()) return const_cast(this); + if (const CXXRecordDecl *CXXRD = dyn_cast(this)) + return CXXRD->getDefinition(); for (redecl_iterator R = redecls_begin(), REnd = redecls_end(); R != REnd; ++R) diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 24ac8f44179b..6bf5598c9307 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1116,13 +1116,13 @@ void ASTWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo Abv->Add(BitCodeAbbrevOp(serialization::PREDEF_TYPE_NULL_ID)); // InfoType // VarDecl + Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration Abv->Add(BitCodeAbbrevOp(0)); // StorageClass Abv->Add(BitCodeAbbrevOp(0)); // StorageClassAsWritten Abv->Add(BitCodeAbbrevOp(0)); // isThreadSpecified Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer Abv->Add(BitCodeAbbrevOp(0)); // isExceptionVariable Abv->Add(BitCodeAbbrevOp(0)); // isNRVOVariable - Abv->Add(BitCodeAbbrevOp(0)); // PrevDecl Abv->Add(BitCodeAbbrevOp(0)); // HasInit Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo // ParmVarDecl diff --git a/clang/test/PCH/Inputs/chain-cxx1.h b/clang/test/PCH/Inputs/chain-cxx1.h deleted file mode 100644 index 7ea3ffb61c8f..000000000000 --- a/clang/test/PCH/Inputs/chain-cxx1.h +++ /dev/null @@ -1,19 +0,0 @@ -// Primary header for C++ chained PCH test - -void f(); - -// Name not appearing in dependent -void pf(); - -namespace ns { - void g(); - - void pg(); -} - -template -struct S { typedef int G; }; - -// Partially specialize -template -struct S { typedef int H; }; diff --git a/clang/test/PCH/Inputs/chain-cxx2.h b/clang/test/PCH/Inputs/chain-cxx2.h deleted file mode 100644 index adc10fd83681..000000000000 --- a/clang/test/PCH/Inputs/chain-cxx2.h +++ /dev/null @@ -1,32 +0,0 @@ -// Dependent header for C++ chained PCH test - -// Overload function from primary -void f(int); - -// Add function with different name -void f2(); - -// Reopen namespace -namespace ns { - // Overload function from primary - void g(int); - - // Add different name - void g2(); -} - -// Specialize template from primary -template <> -struct S { typedef int I; }; - -// Partially specialize -template -struct S { typedef int J; }; - -// Specialize previous partial specialization -template <> -struct S { typedef int K; }; - -// Specialize the partial specialization from this file -template <> -struct S { typedef int L; }; diff --git a/clang/test/PCH/chain-cxx.cpp b/clang/test/PCH/chain-cxx.cpp index 3e46214c70b8..b2d05234106e 100644 --- a/clang/test/PCH/chain-cxx.cpp +++ b/clang/test/PCH/chain-cxx.cpp @@ -1,13 +1,77 @@ // Test C++ chained PCH functionality // Without PCH -// RUN: %clang_cc1 -fsyntax-only -verify -include %S/Inputs/chain-cxx1.h -include %S/Inputs/chain-cxx2.h %s +// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s // With PCH -// RUN: %clang_cc1 -x c++ -emit-pch -o %t1 %S/Inputs/chain-cxx1.h -// RUN: %clang_cc1 -x c++ -emit-pch -o %t2 %S/Inputs/chain-cxx2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t1 %s +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t2 %s -include-pch %t1 -chained-pch // RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s +#ifndef HEADER1 +#define HEADER1 +//===----------------------------------------------------------------------===// +// Primary header for C++ chained PCH test + +void f(); + +// Name not appearing in dependent +void pf(); + +namespace ns { + void g(); + + void pg(); +} + +template +struct S { typedef int G; }; + +// Partially specialize +template +struct S { typedef int H; }; + +//===----------------------------------------------------------------------===// +#elif not defined(HEADER2) +#define HEADER2 +//===----------------------------------------------------------------------===// +// Dependent header for C++ chained PCH test + +// Overload function from primary +void f(int); + +// Add function with different name +void f2(); + +// Reopen namespace +namespace ns { + // Overload function from primary + void g(int); + + // Add different name + void g2(); +} + +// Specialize template from primary +template <> +struct S { typedef int I; }; + +// Partially specialize +template +struct S { typedef int J; }; + +// Specialize previous partial specialization +template <> +struct S { typedef int K; }; + +// Specialize the partial specialization from this file +template <> +struct S { typedef int L; }; + +//===----------------------------------------------------------------------===// +#else +//===----------------------------------------------------------------------===// + void test() { f(); f(1); @@ -26,3 +90,6 @@ void test() { typedef S::K T5; typedef S::L T6; } + +//===----------------------------------------------------------------------===// +#endif