Skip to content

Commit c63f258

Browse files
committed
Enable -Wctad-maybe-unsupported in LLVM build
Warns on potentially unintended use of C++17 Class Template Argument Deduction. Use of this feature with types that aren't intended to support it may may future refactorings of those types more difficult - so this warning fires whenever the feature is used with a type that may not have intended to be used with CTAD (the warning uses the existence of at least one explicit deduction guide to indicate that a type intentionally supports CTAD - absent that, it's assumed to not be intended to support CTAD & produces a warning). This is disabled in libcxx because lots of the standard library is assumed to provide ctad-usable APIs and the false positive suppression in the diagnostic is based on system header classification which doesn't apply in the libcxx build itself. Differential Revision: https://reviews.llvm.org/D131727
1 parent 5a1f864 commit c63f258

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

libcxx/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ function(cxx_add_warning_flags target)
592592
-Wno-user-defined-literals
593593
-Wno-covered-switch-default
594594
-Wno-suggest-override
595+
-Wno-ctad-maybe-unsupported
595596
)
596597
if (LIBCXX_TARGETING_CLANG_CL)
597598
target_add_compile_flags_if_supported(${target} PRIVATE

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,9 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
794794

795795
# Prevent bugs that can happen with llvm's brace style.
796796
add_flag_if_supported("-Wmisleading-indentation" MISLEADING_INDENTATION_FLAG)
797+
798+
# Enable -Wctad-maybe-unsupported to catch unintended use of CTAD.
799+
add_flag_if_supported("-Wctad-maybe-unsupported" CTAD_MAYBE_UNSPPORTED_FLAG)
797800
endif (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
798801

799802
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT LLVM_ENABLE_WARNINGS)

llvm/include/llvm/CodeGen/RDFGraph.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ namespace rdf {
934934
const DataFlowGraph &G;
935935
};
936936

937+
template <typename T> Print(const T &, const DataFlowGraph &) -> Print<T>;
938+
937939
template <typename T>
938940
struct PrintNode : Print<NodeAddr<T>> {
939941
PrintNode(const NodeAddr<T> &x, const DataFlowGraph &g)

0 commit comments

Comments
 (0)