Skip to content

Commit 48df948

Browse files
authored
[NFC] Suppress spurious deprecation warning with MSVC (#124764)
gcc and clang won't complain about calls to deprecated functions, if you're calling from a function that is deprecated too. However, MSVC does care, and expands into maaany deprecation warnings for getFirstNonPHI. Suppress this by converting the inlineable copy of getFirstNonPHI into a non-inline copy.
1 parent 75622e3 commit 48df948

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
287287
const Instruction *getFirstNonPHI() const;
288288
LLVM_DEPRECATED("Use iterators as instruction positions instead",
289289
"getFirstNonPHIIt")
290-
Instruction *getFirstNonPHI() {
291-
return const_cast<Instruction *>(
292-
static_cast<const BasicBlock *>(this)->getFirstNonPHI());
293-
}
290+
Instruction *getFirstNonPHI();
294291

295292
/// Returns an iterator to the first instruction in this block that is not a
296293
/// PHINode instruction.

llvm/lib/IR/BasicBlock.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ const Instruction* BasicBlock::getFirstNonPHI() const {
371371
return nullptr;
372372
}
373373

374+
Instruction *BasicBlock::getFirstNonPHI() {
375+
for (Instruction &I : *this)
376+
if (!isa<PHINode>(I))
377+
return &I;
378+
return nullptr;
379+
}
380+
374381
BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
375382
for (const Instruction &I : *this) {
376383
if (isa<PHINode>(I))

0 commit comments

Comments
 (0)