Skip to content

Conversation

@shafik
Copy link
Collaborator

@shafik shafik commented Mar 4, 2025

Static analysis flags the final return statement in ReadExtensionBlock as unreachable and indeed it is since there is no way to exit the while(true) loop besides a return statement.

So I am converting it into a llvm_unreachable to explicitly document this.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:modules C++20 modules and Clang Header Modules labels Mar 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 4, 2025

@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

Static analysis flags the final return statement in ReadExtensionBlock as unreachable and indeed it is since there is no way to exit the while(true) loop besides a return statement.

So I am converting it into a llvm_unreachable to explicitly document this.


Full diff: https://github.com/llvm/llvm-project/pull/129627.diff

1 Files Affected:

  • (modified) clang/lib/Serialization/ASTReader.cpp (+1-1)
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index ea4b233a6c573..ca09c3d79d941 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5329,7 +5329,7 @@ llvm::Error ASTReader::ReadExtensionBlock(ModuleFile &F) {
     }
   }
 
-  return llvm::Error::success();
+  llvm_unreachable("ReadExtensionBlock should return from while loop");
 }
 
 void ASTReader::InitializeContext() {

Copy link
Contributor

@tahonermann tahonermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shafik shafik merged commit 4b454af into llvm:main Mar 6, 2025
14 checks passed
@shafik shafik deleted the ReadExtensionBlock_unreachable_return branch March 7, 2025 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants