summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-20 16:04:09 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-20 16:04:09 +0000
commite394f2ca8bb845d6d25e99c2438d5aa4c36dffd3 (patch)
tree9b8e5c8eb31fd14e4269865dd049504644a50974 /clang/lib/Serialization/ASTWriter.cpp
parenta7fbbb054682d3e44ef40506cc049a05ca3f2862 (diff)
downloadbcm5719-llvm-e394f2ca8bb845d6d25e99c2438d5aa4c36dffd3.tar.gz
bcm5719-llvm-e394f2ca8bb845d6d25e99c2438d5aa4c36dffd3.zip
A bit of refactoring; Introduce ASTWriter::GetOrCreateTypeIdx and move the emission of types there.
No functionality change. llvm-svn: 111632
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index b421b857b41..16c6f4b1010 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud