[clang-tools-extra] [clang-tidy] Add performance-expensive-value-or check (PR #200166)
Endre Fülöp via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 02:06:20 PDT 2026
================
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ExpensiveValueOrCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+ExpensiveValueOrCheck::ExpensiveValueOrCheck(StringRef Name,
+ ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ SizeThreshold(Options.get("SizeThreshold", 8U)),
+ WarnOnRvalueOptional(Options.get("WarnOnRvalueOptional", false)),
+ OptionalTypes(utils::options::parseStringList(
+ Options.get("OptionalTypes", "::std::optional"))) {}
----------------
gamesh411 wrote:
I also think this would not lead to false positives.
The 'value_or' naming suggests clear adherence to how optionals work.
https://github.com/llvm/llvm-project/pull/200166
More information about the cfe-commits
mailing list