[llvm] [NFC] Suppress spurious deprecation warning with MSVC (PR #124764)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 07:19:03 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Jeremy Morse (jmorse)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/124764.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/BasicBlock.h (+1-4)
- (modified) llvm/lib/IR/BasicBlock.cpp (+7)
``````````diff
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 2ee17ce8f483ea..c9169cb6018096 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -287,10 +287,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
const Instruction *getFirstNonPHI() const;
LLVM_DEPRECATED("Use iterators as instruction positions instead",
"getFirstNonPHIIt")
- Instruction *getFirstNonPHI() {
- return const_cast<Instruction *>(
- static_cast<const BasicBlock *>(this)->getFirstNonPHI());
- }
+ Instruction *getFirstNonPHI();
/// Returns an iterator to the first instruction in this block that is not a
/// PHINode instruction.
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 8eaa6e522f826a..d3d382fe500e9f 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -371,6 +371,13 @@ const Instruction* BasicBlock::getFirstNonPHI() const {
return nullptr;
}
+Instruction* BasicBlock::getFirstNonPHI() {
+ for (Instruction &I : *this)
+ if (!isa<PHINode>(I))
+ return &I;
+ return nullptr;
+}
+
BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
for (const Instruction &I : *this) {
if (isa<PHINode>(I))
``````````
</details>
https://github.com/llvm/llvm-project/pull/124764
More information about the llvm-commits
mailing list