]> granicus.if.org Git - clang/commitdiff
[TI removal] Make `getTerminator()` return a generic `Instruction`.
authorChandler Carruth <chandlerc@gmail.com>
Mon, 15 Oct 2018 10:42:50 +0000 (10:42 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 15 Oct 2018 10:42:50 +0000 (10:42 +0000)
This removes the primary remaining API producing `TerminatorInst` which
will reduce the rate at which code is introduced trying to use it and
generally make it much easier to remove the remaining APIs across the
codebase.

Also clean up some of the stragglers that the previous mechanical update
of variables missed.

Users of LLVM and out-of-tree code generally will need to update any
explicit variable types to handle this. Replacing `TerminatorInst` with
`Instruction` (or `auto`) almost always works. Most of these edits were
made in prior commits using the perl one-liner:
```
perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g'
```

This also my break some rare use cases where people overload for both
`Instruction` and `TerminatorInst`, but these should be easily fixed by
removing the `TerminatorInst` overload.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344504 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCleanup.cpp
lib/CodeGen/CGException.cpp

index 0a766d17620023fcb5d17b73e96bec1a99c08529..3743d24f11fc08409622a71243a4efd9dc39a88f 100644 (file)
@@ -366,7 +366,7 @@ static llvm::SwitchInst *TransitionToCleanupSwitch(CodeGenFunction &CGF,
                                                    llvm::BasicBlock *Block) {
   // If it's a branch, turn it into a switch whose default
   // destination is its original target.
-  llvm::TerminatorInst *Term = Block->getTerminator();
+  llvm::Instruction *Term = Block->getTerminator();
   assert(Term && "can't transition block without terminator");
 
   if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
@@ -589,7 +589,7 @@ static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit,
                                           llvm::BasicBlock *To) {
   // Exit is the exit block of a cleanup, so it always terminates in
   // an unconditional branch or a switch.
-  llvm::TerminatorInst *Term = Exit->getTerminator();
+  llvm::Instruction *Term = Exit->getTerminator();
 
   if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
     assert(Br->isUnconditional() && Br->getSuccessor(0) == From);
index 4ee835259a54dec76c81091950a8f2bede0b06e7..3297bb319db5b7c587a9d0c879738e6bf8df2275 100644 (file)
@@ -1248,7 +1248,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
     // we follow the false destination for each of the cond branches to reach
     // the rethrow block.
     llvm::BasicBlock *RethrowBlock = WasmCatchStartBlock;
-    while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) {
+    while (llvm::Instruction *TI = RethrowBlock->getTerminator()) {
       auto *BI = cast<llvm::BranchInst>(TI);
       assert(BI->isConditional());
       RethrowBlock = BI->getSuccessor(1);