From a4ca6face4cbea5f55b0c1d650f47ef72fda2bfb Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 16 Mar 2015 20:11:03 +0000 Subject: [PATCH] Lambdaify some helper functions. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232407 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTWriter.h | 6 --- lib/Serialization/ASTWriter.cpp | 60 +++++++++++-------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 175ee7a3b3..27c8424693 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -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); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 15e7de48c9..5bf1dcdd64 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -4999,46 +4999,40 @@ void ASTWriter::AddTypeRef(QualType T, RecordDataImpl &Record) { 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)); -} - -TypeID ASTWriter::getTypeID(QualType T) const { - assert(Context); - return MakeTypeID(*Context, T, - std::bind1st(std::mem_fun(&ASTWriter::getTypeIdx), this)); -} + return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx { + if (T.isNull()) + return TypeIdx(); + assert(!T.getLocalFastQualifiers()); -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 TypeIdx(); + } - 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); } - - // 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; + return Idx; + }); } -TypeIdx ASTWriter::getTypeIdx(QualType T) const { - if (T.isNull()) - return TypeIdx(); - assert(!T.getLocalFastQualifiers()); +TypeID ASTWriter::getTypeID(QualType T) const { + assert(Context); + return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx { + 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) { -- 2.40.0