diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-20 16:04:09 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-20 16:04:09 +0000 |
commit | 26fca90786af17f97e1a5ecc310d4bf39b831595 (patch) | |
tree | 895338fc27b950fca590cd86f12f8e7b2221277a /lib/Serialization/ASTWriter.cpp | |
parent | 01b81c4d074bba9c18372d521405dfe32fc4f552 (diff) |
A bit of refactoring; Introduce ASTWriter::GetOrCreateTypeIdx and move the emission of types there.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index b421b857b4..16c6f4b101 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2588,14 +2588,7 @@ void ASTWriter::AddTypeRef(QualType T, RecordData &Record) { T.removeFastQualifiers(); if (T.hasLocalNonFastQualifiers()) { - TypeIdx &Idx = TypeIdxs[T]; - if (Idx.getIndex() == 0) { - // We haven't seen these qualifiers applied to this type before. - // Assign it a new ID. This is the only time we enqueue a - // qualified type, and it has no CV qualifiers. - Idx = TypeIdx(NextTypeID++); - DeclTypesToEmit.push(T); - } + TypeIdx Idx = GetOrCreateTypeIdx(T); // Encode the type qualifiers in the type reference. Record.push_back(Idx.asTypeID(FastQuals)); @@ -2644,6 +2637,17 @@ void ASTWriter::AddTypeRef(QualType T, RecordData &Record) { return; } + TypeIdx Idx = GetOrCreateTypeIdx(T); + + // Encode the type qualifiers in the type reference. + Record.push_back(Idx.asTypeID(FastQuals)); +} + +TypeIdx ASTWriter::GetOrCreateTypeIdx(QualType T) { + if (T.isNull()) + return TypeIdx(); + assert(!T.getLocalFastQualifiers()); + TypeIdx &Idx = TypeIdxs[T]; if (Idx.getIndex() == 0) { // We haven't seen this type before. Assign it a new ID and put it @@ -2651,9 +2655,16 @@ void ASTWriter::AddTypeRef(QualType T, RecordData &Record) { Idx = TypeIdx(NextTypeID++); DeclTypesToEmit.push(T); } + return Idx; +} - // Encode the type qualifiers in the type reference. - Record.push_back(Idx.asTypeID(FastQuals)); +TypeIdx ASTWriter::getTypeIdx(QualType T) { + if (T.isNull()) + return TypeIdx(); + assert(!T.getLocalFastQualifiers()); + + assert(TypeIdxs.find(T) != TypeIdxs.end() && "Type not emitted!"); + return TypeIdxs[T]; } void ASTWriter::AddDeclRef(const Decl *D, RecordData &Record) { |