[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 14:28:57 PDT 2023


PiotrZSL added a comment.

There are 37 findings in llvm repository:

1. clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:96:12: warning: conversion from 'std::optional<bool>' into 'bool' and back into 'std::optional<bool>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
2. clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:65:12: warning: conversion from 'std::optional<std::basic_string<char>>' into 'std::basic_string<char>' and back into 'std::optional<std::basic_string<char>>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
3. clang/lib/AST/Interp/Program.cpp:173:12: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
4. clang/lib/Analysis/PathDiagnostic.cpp:323:14: warning: conversion from 'std::optional<bool>' into 'bool' and back into 'std::optional<bool>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
5. clang/lib/Frontend/Rewrite/InclusionRewriter.cpp:253:7: warning: conversion from 'std::optional<llvm::MemoryBufferRef>' into 'llvm::MemoryBufferRef' and back into 'std::optional<llvm::MemoryBufferRef>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
6. clang/lib/Sema/Scope.cpp:190:25: warning: conversion from 'std::optional<clang::VarDecl *>' into 'clang::VarDecl *' and back into 'std::optional<clang::VarDecl *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
7. clang/lib/Sema/TreeTransform.h:13915:9: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
8. clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:440:16: warning: conversion from 'std::optional<int>' into 'int' and back into 'std::optional<int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
9. clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp:125:10: warning: conversion from 'std::optional<bool>' into 'bool' and back into 'std::optional<bool>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
10. clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1573:10: warning: conversion from 'std::optional<clang::ento::nonloc::LazyCompoundVal>' into 'clang::ento::nonloc::LazyCompoundVal' and back into 'std::optional<clang::ento::nonloc::LazyCompoundVal>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
11. clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1784:12: warning: conversion from 'std::optional<clang::ento::SVal>' into 'clang::ento::SVal' and back into 'std::optional<clang::ento::SVal>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
12. clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:189:16: warning: conversion from 'std::optional<clang::driver::types::ID>' into 'clang::driver::types::ID' and back into 'std::optional<clang::driver::types::ID>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
13. lldb/source/Breakpoint/BreakpointResolver.cpp:233:33: warning: conversion from 'std::optional<unsigned short>' into 'unsigned short' and back into 'std::optional<unsigned short>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
14. lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1362:53: warning: conversion from 'std::optional<unsigned long>' into 'unsigned long' and back into 'std::optional<unsigned long>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
15. llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp:4119:12: warning: conversion from 'std::optional<LiveDebugValues::ValueIDNum>' into 'LiveDebugValues::ValueIDNum' and back into 'std::optional<LiveDebugValues::ValueIDNum>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
16. llvm/lib/DWARFLinker/DWARFLinker.cpp:1191:14: warning: conversion from 'std::optional<unsigned long>' into 'unsigned long' and back into 'std::optional<unsigned long>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
17. llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1305:31: warning: conversion from 'std::optional<long>' into 'long' and back into 'std::optional<long>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
18. llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1322:62: warning: conversion from 'std::optional<llvm::DWARFFormValue>' into 'llvm::DWARFFormValue' and back into 'std::optional<llvm::DWARFFormValue>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
19. llvm/lib/DebugInfo/Symbolize/Markup.cpp:67:14: warning: conversion from 'std::optional<llvm::symbolize::MarkupNode>' into 'llvm::symbolize::MarkupNode' and back into 'std::optional<llvm::symbolize::MarkupNode>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
20. llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp:425:13: warning: conversion from 'std::optional<llvm::raw_ostream::Colors>' into 'llvm::raw_ostream::Colors' and back into 'std::optional<llvm::raw_ostream::Colors>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
21. llvm/lib/InterfaceStub/IFSHandler.cpp:231:24: warning: conversion from 'std::optional<unsigned short>' into 'unsigned short' and back into 'std::optional<unsigned short>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
22. llvm/lib/InterfaceStub/IFSHandler.cpp:239:30: warning: conversion from 'std::optional<llvm::ifs::IFSEndiannessType>' into 'llvm::ifs::IFSEndiannessType' and back into 'std::optional<llvm::ifs::IFSEndiannessType>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
23. llvm/lib/InterfaceStub/IFSHandler.cpp:246:28: warning: conversion from 'std::optional<llvm::ifs::IFSBitWidthType>' into 'llvm::ifs::IFSBitWidthType' and back into 'std::optional<llvm::ifs::IFSBitWidthType>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
24. llvm/lib/LTO/LTOBackend.cpp:214:18: warning: conversion from 'std::optional<llvm::Reloc::Model>' into 'llvm::Reloc::Model' and back into 'std::optional<llvm::Reloc::Model>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
25. llvm/lib/LTO/LTOBackend.cpp:221:17: warning: conversion from 'std::optional<llvm::CodeModel::Model>' into 'llvm::CodeModel::Model' and back into 'std::optional<llvm::CodeModel::Model>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
26. llvm/lib/Remarks/BitstreamRemarkParser.cpp:563:17: warning: conversion from 'std::optional<unsigned long>' into 'unsigned long' and back into 'std::optional<unsigned long>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
27. llvm/lib/Support/UnicodeNameToCodepoint.cpp:382:12: warning: conversion from 'std::optional<char32_t>' into 'char32_t' and back into 'std::optional<char32_t>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
28. llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:1028:12: warning: conversion from 'std::optional<llvm::Value *>' into 'llvm::Value *' and back into 'std::optional<llvm::Value *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
29. llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4651:33: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
30. llvm/lib/Transforms/Utils/ValueMapper.cpp:576:12: warning: conversion from 'std::optional<llvm::Metadata *>' into 'llvm::Metadata *' and back into 'std::optional<llvm::Metadata *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
31. llvm/lib/Transforms/Utils/ValueMapper.cpp:615:12: warning: conversion from 'std::optional<llvm::Metadata *>' into 'llvm::Metadata *' and back into 'std::optional<llvm::Metadata *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
32. llvm/lib/Transforms/Utils/ValueMapper.cpp:832:12: warning: conversion from 'std::optional<llvm::Metadata *>' into 'llvm::Metadata *' and back into 'std::optional<llvm::Metadata *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
33. llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:435:14: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
34. llvm/tools/llvm-lto2/llvm-lto2.cpp:264:23: warning: conversion from 'std::optional<llvm::Reloc::Model>' into 'llvm::Reloc::Model' and back into 'std::optional<llvm::Reloc::Model>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
35. llvm/tools/llvm-profgen/ProfiledBinary.cpp:104:14: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
36. llvm/tools/llvm-profgen/ProfiledBinary.cpp:118:16: warning: conversion from 'std::optional<unsigned int>' into 'unsigned int' and back into 'std::optional<unsigned int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
37. llvm/utils/TableGen/GlobalISelEmitter.cpp:5217:12: warning: conversion from 'std::optional<const llvm::CodeGenRegisterClass *>' into 'const llvm::CodeGenRegisterClass *' and back into 'std::optional<const llvm::CodeGenRegisterClass *>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147357/new/

https://reviews.llvm.org/D147357



More information about the cfe-commits mailing list