r232407 - Lambdaify some helper functions. No functionality change.
Richard Smith
richard-llvm at metafoo.co.uk
Mon Mar 16 13:11:03 PDT 2015
Author: rsmith
Date: Mon Mar 16 15:11:03 2015
New Revision: 232407
URL: http://llvm.org/viewvc/llvm-project?rev=232407&view=rev
Log:
Lambdaify some helper functions. 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=232407&r1=232406&r2=232407&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Mar 16 15:11:03 2015
@@ -606,12 +606,6 @@ public:
/// \brief Determine the type ID of an already-emitted type.
serialization::TypeID getTypeID(QualType T) const;
- /// \brief Force a type to be emitted and get its index.
- serialization::TypeIdx GetOrCreateTypeIdx( QualType T);
-
- /// \brief Determine the type index of an already-emitted type.
- serialization::TypeIdx getTypeIdx(QualType T) const;
-
/// \brief Emits a reference to a declarator info.
void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record);
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=232407&r1=232406&r2=232407&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Mar 16 15:11:03 2015
@@ -4999,46 +4999,40 @@ void ASTWriter::AddTypeRef(QualType T, R
Record.push_back(GetOrCreateTypeID(T));
}
-TypeID ASTWriter::GetOrCreateTypeID( QualType T) {
+TypeID ASTWriter::GetOrCreateTypeID(QualType T) {
assert(Context);
- return MakeTypeID(*Context, T,
- std::bind1st(std::mem_fun(&ASTWriter::GetOrCreateTypeIdx), this));
+ return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx {
+ if (T.isNull())
+ return TypeIdx();
+ assert(!T.getLocalFastQualifiers());
+
+ TypeIdx &Idx = TypeIdxs[T];
+ if (Idx.getIndex() == 0) {
+ if (DoneWritingDeclsAndTypes) {
+ assert(0 && "New type seen after serializing all the types to emit!");
+ return TypeIdx();
+ }
+
+ // We haven't seen this type before. Assign it a new ID and put it
+ // into the queue of types to emit.
+ Idx = TypeIdx(NextTypeID++);
+ DeclTypesToEmit.push(T);
+ }
+ return Idx;
+ });
}
TypeID ASTWriter::getTypeID(QualType T) const {
assert(Context);
- return MakeTypeID(*Context, T,
- std::bind1st(std::mem_fun(&ASTWriter::getTypeIdx), this));
-}
-
-TypeIdx ASTWriter::GetOrCreateTypeIdx(QualType T) {
- if (T.isNull())
- return TypeIdx();
- assert(!T.getLocalFastQualifiers());
-
- TypeIdx &Idx = TypeIdxs[T];
- if (Idx.getIndex() == 0) {
- if (DoneWritingDeclsAndTypes) {
- assert(0 && "New type seen after serializing all the types to emit!");
+ return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx {
+ if (T.isNull())
return TypeIdx();
- }
-
- // We haven't seen this type before. Assign it a new ID and put it
- // into the queue of types to emit.
- Idx = TypeIdx(NextTypeID++);
- DeclTypesToEmit.push(T);
- }
- return Idx;
-}
+ assert(!T.getLocalFastQualifiers());
-TypeIdx ASTWriter::getTypeIdx(QualType T) const {
- if (T.isNull())
- return TypeIdx();
- assert(!T.getLocalFastQualifiers());
-
- TypeIdxMap::const_iterator I = TypeIdxs.find(T);
- assert(I != TypeIdxs.end() && "Type not emitted!");
- return I->second;
+ TypeIdxMap::const_iterator I = TypeIdxs.find(T);
+ assert(I != TypeIdxs.end() && "Type not emitted!");
+ return I->second;
+ });
}
void ASTWriter::AddDeclRef(const Decl *D, RecordDataImpl &Record) {
More information about the cfe-commits
mailing list