[cfe-commits] r110378 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHWriterDecl.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Thu Aug 5 14:22:19 PDT 2010
Author: cornedbee
Date: Thu Aug 5 16:22:19 2010
New Revision: 110378
URL: http://llvm.org/viewvc/llvm-project?rev=110378&view=rev
Log:
Collect namespaces that need updating in a PCH chain. WIP
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Frontend/PCHWriter.h
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=110378&r1=110377&r2=110378&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Aug 5 16:22:19 2010
@@ -239,7 +239,7 @@
// there will be one NamespaceDecl for each declaration.
// NextNamespace points to the next extended declaration.
// OrigNamespace points to the original namespace declaration.
- // OrigNamespace of the first namespace decl points to itself.
+ // OrigNamespace of the first namespace decl points to its anonymous namespace
NamespaceDecl *NextNamespace;
/// \brief A pointer to either the original namespace definition for
@@ -277,7 +277,7 @@
return !getIdentifier();
}
- /// \brief Return the next extended namespace declaration or null if this
+ /// \brief Return the next extended namespace declaration or null if there
/// is none.
NamespaceDecl *getNextNamespace() { return NextNamespace; }
const NamespaceDecl *getNextNamespace() const { return NextNamespace; }
Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=110378&r1=110377&r2=110378&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Thu Aug 5 16:22:19 2010
@@ -22,6 +22,7 @@
#include "clang/Frontend/PCHDeserializationListener.h"
#include "clang/Sema/SemaConsumer.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Bitcode/BitstreamWriter.h"
#include <map>
@@ -219,6 +220,13 @@
/// record.
llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
+ /// \brief Namespaces that have received extensions since their PCH form.
+ ///
+ /// Basically, when we're chaining and encountering a namespace, we check if
+ /// its primary namespace comes from the chain. If it does, we add the primary
+ /// to this set, so that we can write out lexical content updates for it.
+ llvm::SmallPtrSet<const NamespaceDecl *, 16> UpdatedNamespaces;
+
/// \brief Statements that we've encountered while serializing a
/// declaration or type.
llvm::SmallVector<Stmt *, 16> StmtsToEmit;
@@ -390,12 +398,17 @@
/// \brief Emit a UnresolvedSet structure.
void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record);
- /// brief Emit a C++ base specifier.
+ /// \brief Emit a C++ base specifier.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordData &Record);
/// \brief Add a string to the given record.
void AddString(const std::string &Str, RecordData &Record);
+ /// \brief Mark a namespace as needing an update.
+ void AddUpdatedNamespace(const NamespaceDecl *NS) {
+ UpdatedNamespaces.insert(NS);
+ }
+
/// \brief Note that the identifier II occurs at the given offset
/// within the identifier table.
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=110378&r1=110377&r2=110378&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Thu Aug 5 16:22:19 2010
@@ -600,6 +600,11 @@
else
Writer.AddDeclRef(D->getOriginalNamespace(), Record);
Code = pch::DECL_NAMESPACE;
+
+ if (Writer.hasChain() && !D->isOriginalNamespace() &&
+ D->getOriginalNamespace()->getPCHLevel() > 0) {
+ Writer.AddUpdatedNamespace(D->getOriginalNamespace());
+ }
}
void PCHDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
More information about the cfe-commits
mailing list