[llvm] cfc385d - X86FoldTablesEmitter - fix static analyzer potential invalid iterator warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 06:03:10 PST 2019


Author: Simon Pilgrim
Date: 2019-11-06T13:31:00Z
New Revision: cfc385d95445ea52ac68d55f2c13ac8d19f79855

URL: https://github.com/llvm/llvm-project/commit/cfc385d95445ea52ac68d55f2c13ac8d19f79855
DIFF: https://github.com/llvm/llvm-project/commit/cfc385d95445ea52ac68d55f2c13ac8d19f79855.diff

LOG: X86FoldTablesEmitter - fix static analyzer potential invalid iterator warning. NFCI.

Added: 
    

Modified: 
    llvm/utils/TableGen/X86FoldTablesEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
index 2c15e35f234d..8026c324cd40 100644
--- a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -618,14 +618,14 @@ void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) {
     uint8_t Opc =
         getValueFromBitsInit(MemInst->TheDef->getValueAsBitsInit("Opcode"));
 
-    if (RegInsts.count(Opc) == 0)
+    auto RegInstsIt = RegInsts.find(Opc);
+    if (RegInstsIt == RegInsts.end())
       continue;
 
     // Two forms (memory & register) of the same instruction must have the same
     // opcode. try matching only with register form instructions with the same
     // opcode.
-    std::vector<const CodeGenInstruction *> &OpcRegInsts =
-        RegInsts.find(Opc)->second;
+    std::vector<const CodeGenInstruction *> &OpcRegInsts = RegInstsIt->second;
 
     auto Match = find_if(OpcRegInsts, IsMatch(MemInst, Records));
     if (Match != OpcRegInsts.end()) {


        


More information about the llvm-commits mailing list