Skip to content

Conversation

dpaoliello
Copy link
Contributor

Fixes this error:

llvm\clang\lib\Driver\ToolChains\CommonArgs.cpp(3523) : warning C4715: 'clang::driver::tools::complexRangeKindToStr': not all control paths return a value

This was not seen in the builders as they use MSVC 2019.

Opted to add an llvm_unreachable after the switch instead of a default so that Clang's warnings about uncovered enum values will still trigger. This matches #112767 and #139309.

Also removed the dead break statements after the returns.

…ng::driver::tools::complexRangeKindToStr': not all control paths return a value
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Sep 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Daniel Paoliello (dpaoliello)

Changes

Fixes this error:

llvm\clang\lib\Driver\ToolChains\CommonArgs.cpp(3523) : warning C4715: 'clang::driver::tools::complexRangeKindToStr': not all control paths return a value

This was not seen in the builders as they use MSVC 2019.

Opted to add an llvm_unreachable after the switch instead of a default so that Clang's warnings about uncovered enum values will still trigger. This matches #112767 and #139309.

Also removed the dead break statements after the returns.


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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-5)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b50549219e4e8..716e04003f065 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -3506,20 +3506,16 @@ std::string tools::complexRangeKindToStr(LangOptions::ComplexRangeKind Range) {
   switch (Range) {
   case LangOptions::ComplexRangeKind::CX_Full:
     return "full";
-    break;
   case LangOptions::ComplexRangeKind::CX_Basic:
     return "basic";
-    break;
   case LangOptions::ComplexRangeKind::CX_Improved:
     return "improved";
-    break;
   case LangOptions::ComplexRangeKind::CX_Promoted:
     return "promoted";
-    break;
   case LangOptions::ComplexRangeKind::CX_None:
     return "none";
-    break;
   }
+  llvm_unreachable("Unknown ComplexRangeKind!");
 }
 
 std::string

Copy link
Contributor

@s-watanabe314 s-watanabe314 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. However, llvm_unreachable seems to have already been merged in #159330. Removing the break is fine.

@dpaoliello dpaoliello closed this Sep 18, 2025
@dpaoliello dpaoliello deleted the comarg branch September 18, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants