[llvm] ba59ec2 - Fix a misuse of `cast`

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 10 18:22:47 PDT 2022


Author: Sheng
Date: 2022-04-11T01:21:15Z
New Revision: ba59ec2843f99f19d55d7cd9f9ac536fb038fdab

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

LOG: Fix a misuse of `cast`

`cast` will assert instead of returning null pointer.

Added: 
    

Modified: 
    llvm/utils/TableGen/FixedLenDecoderEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
index bbb5d4725307f..33be554febc8c 100644
--- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -1970,7 +1970,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
           CGI.Operands[SO.first].MIOperandInfo->getNumArgs()) {
         Init *Arg = CGI.Operands[SO.first].MIOperandInfo->
                       getArg(SO.second);
-        if (DefInit *DI = cast<DefInit>(Arg))
+        if (DefInit *DI = dyn_cast<DefInit>(Arg))
           TypeRecord = DI->getDef();
       }
 


        


More information about the llvm-commits mailing list