[cfe-commits] r107566 - in /cfe/trunk: include/clang/AST/Decl.h lib/Frontend/PCHReaderDecl.cpp test/PCH/cxx-namespaces.cpp test/PCH/cxx-namespaces.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Jul 3 00:57:53 PDT 2010
Author: akirtzidis
Date: Sat Jul 3 02:57:53 2010
New Revision: 107566
URL: http://llvm.org/viewvc/llvm-project?rev=107566&view=rev
Log:
When setting the anonymous namespace at PCH reading, it may still be initializing so avoid
the invariant checks at NamespaceDecl::setAnonymousNamespace().
Added:
cfe/trunk/test/PCH/cxx-namespaces.cpp
cfe/trunk/test/PCH/cxx-namespaces.h
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=107566&r1=107565&r2=107566&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Jul 3 02:57:53 2010
@@ -344,6 +344,9 @@
static NamespaceDecl *castFromDeclContext(const DeclContext *DC) {
return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
}
+
+ friend class PCHDeclReader;
+ friend class PCHDeclWriter;
};
/// ValueDecl - Represent the declaration of a variable (in which case it is
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=107566&r1=107565&r2=107566&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Sat Jul 3 02:57:53 2010
@@ -564,13 +564,9 @@
D->setNextNamespace(
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
- // Only read one reference--the original or anonymous namespace.
bool IsOriginal = Record[Idx++];
- if (IsOriginal)
- D->setAnonymousNamespace(
- cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
- else
- D->setOriginalNamespace(
+ D->OrigOrAnonNamespace.setInt(IsOriginal);
+ D->OrigOrAnonNamespace.setPointer(
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
}
Added: cfe/trunk/test/PCH/cxx-namespaces.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-namespaces.cpp?rev=107566&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-namespaces.cpp (added)
+++ cfe/trunk/test/PCH/cxx-namespaces.cpp Sat Jul 3 02:57:53 2010
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-namespaces.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-namespaces.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void m() {
+ N::x = 0;
+}
Added: cfe/trunk/test/PCH/cxx-namespaces.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-namespaces.h?rev=107566&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-namespaces.h (added)
+++ cfe/trunk/test/PCH/cxx-namespaces.h Sat Jul 3 02:57:53 2010
@@ -0,0 +1,7 @@
+// Header for PCH test cxx-namespaces.cpp
+
+namespace N {
+ namespace {
+ int x;
+ }
+}
More information about the cfe-commits
mailing list