[cfe-commits] r111633 - in /cfe/trunk: include/clang/Serialization/ASTWriter.h lib/Serialization/ASTWriter.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Aug 20 09:04:15 PDT 2010


Author: akirtzidis
Date: Fri Aug 20 11:04:14 2010
New Revision: 111633

URL: http://llvm.org/viewvc/llvm-project?rev=111633&view=rev
Log:
Introduce ASTWriter::GetOrCreateTypeID and move most of the functionality of AddTypeRef there.
No functionality change.

Modified:
    cfe/trunk/include/clang/Serialization/ASTWriter.h
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=111633&r1=111632&r2=111633&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Aug 20 11:04:14 2010
@@ -364,6 +364,9 @@
   /// \brief Emit a reference to a type.
   void AddTypeRef(QualType T, RecordData &Record);
 
+  /// \brief Force a type to be emitted and get its ID.
+  serialization::TypeID GetOrCreateTypeID(QualType T);
+
   /// \brief Force a type to be emitted and get its index.
   serialization::TypeIdx GetOrCreateTypeIdx(QualType T);
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=111633&r1=111632&r2=111633&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Aug 20 11:04:14 2010
@@ -2579,21 +2579,18 @@
 }
 
 void ASTWriter::AddTypeRef(QualType T, RecordData &Record) {
-  if (T.isNull()) {
-    Record.push_back(PREDEF_TYPE_NULL_ID);
-    return;
-  }
+  Record.push_back(GetOrCreateTypeID(T));
+}
+
+TypeID ASTWriter::GetOrCreateTypeID(QualType T) {
+  if (T.isNull())
+    return PREDEF_TYPE_NULL_ID;
 
   unsigned FastQuals = T.getLocalFastQualifiers();
   T.removeFastQualifiers();
 
-  if (T.hasLocalNonFastQualifiers()) {
-    TypeIdx Idx = GetOrCreateTypeIdx(T);
-
-    // Encode the type qualifiers in the type reference.
-    Record.push_back(Idx.asTypeID(FastQuals));
-    return;
-  }
+  if (T.hasLocalNonFastQualifiers())
+    return GetOrCreateTypeIdx(T).asTypeID(FastQuals);
 
   assert(!T.hasLocalQualifiers());
 
@@ -2633,14 +2630,10 @@
       break;
     }
 
-    Record.push_back(TypeIdx(ID).asTypeID(FastQuals));
-    return;
+    return TypeIdx(ID).asTypeID(FastQuals);
   }
 
-  TypeIdx Idx = GetOrCreateTypeIdx(T);
-
-  // Encode the type qualifiers in the type reference.
-  Record.push_back(Idx.asTypeID(FastQuals));
+  return GetOrCreateTypeIdx(T).asTypeID(FastQuals);
 }
 
 TypeIdx ASTWriter::GetOrCreateTypeIdx(QualType T) {





More information about the cfe-commits mailing list