Author: rsmith Date: Fri Jul 17 15:09:43 2015 New Revision: 242564 URL: http://llvm.org/viewvc/llvm-project?rev=242564&view=rev Log: Refactor to remove repetition, no functionality change.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=242564&r1=242563&r2=242564&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jul 17 15:09:43 2015 @@ -744,6 +744,12 @@ static bool isInterestingIdentifier(Iden II.getFETokenInfo<void>(); } +static bool readBit(unsigned &Bits) { + bool Value = Bits & 0x1; + Bits >>= 1; + return Value; +} + IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, const unsigned char* d, unsigned DataLen) { @@ -754,57 +760,38 @@ IdentifierInfo *ASTIdentifierLookupTrait // Wipe out the "is interesting" bit. RawID = RawID >> 1; + // Build the IdentifierInfo and link the identifier ID with it. + IdentifierInfo *II = KnownII; + if (!II) { + II = &Reader.getIdentifierTable().getOwn(k); + KnownII = II; + } + if (!II->isFromAST()) { + II->setIsFromAST(); + if (isInterestingIdentifier(*II)) + II->setChangedSinceDeserialization(); + } + Reader.markIdentifierUpToDate(II); + IdentID ID = Reader.getGlobalIdentifierID(F, RawID); if (!IsInteresting) { - // For uninteresting identifiers, just build the IdentifierInfo - // and associate it with the persistent ID. - IdentifierInfo *II = KnownII; - if (!II) { - II = &Reader.getIdentifierTable().getOwn(k); - KnownII = II; - } + // For uninteresting identifiers, there's nothing else to do. Just notify + // the reader that we've finished loading this identifier. Reader.SetIdentifierInfo(ID, II); - if (!II->isFromAST()) { - bool WasInteresting = isInterestingIdentifier(*II); - II->setIsFromAST(); - if (WasInteresting) - II->setChangedSinceDeserialization(); - } - Reader.markIdentifierUpToDate(II); return II; } unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d); unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d); - bool CPlusPlusOperatorKeyword = Bits & 0x01; - Bits >>= 1; - bool HasRevertedTokenIDToIdentifier = Bits & 0x01; - Bits >>= 1; - bool Poisoned = Bits & 0x01; - Bits >>= 1; - bool ExtensionToken = Bits & 0x01; - Bits >>= 1; - bool hadMacroDefinition = Bits & 0x01; - Bits >>= 1; + bool CPlusPlusOperatorKeyword = readBit(Bits); + bool HasRevertedTokenIDToIdentifier = readBit(Bits); + bool Poisoned = readBit(Bits); + bool ExtensionToken = readBit(Bits); + bool HadMacroDefinition = readBit(Bits); assert(Bits == 0 && "Extra bits in the identifier?"); DataLen -= 8; - // Build the IdentifierInfo itself and link the identifier ID with - // the new IdentifierInfo. - IdentifierInfo *II = KnownII; - if (!II) { - II = &Reader.getIdentifierTable().getOwn(StringRef(k)); - KnownII = II; - } - Reader.markIdentifierUpToDate(II); - if (!II->isFromAST()) { - bool WasInteresting = isInterestingIdentifier(*II); - II->setIsFromAST(); - if (WasInteresting) - II->setChangedSinceDeserialization(); - } - // Set or check the various bits in the IdentifierInfo structure. // Token IDs are read-only. if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier) @@ -821,7 +808,7 @@ IdentifierInfo *ASTIdentifierLookupTrait // If this identifier is a macro, deserialize the macro // definition. - if (hadMacroDefinition) { + if (HadMacroDefinition) { uint32_t MacroDirectivesOffset = endian::readNext<uint32_t, little, unaligned>(d); DataLen -= 4; _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits