Skip to content

Commit

Permalink
Make clang-tidy plugin compatible with LLVM 17
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettDong committed Feb 2, 2024
1 parent 03a693c commit 78fa850
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/clang-tidy-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if (CATA_CLANG_TIDY_EXECUTABLE)
else ()
set(CataAnalyzerName CataAnalyzerPlugin)
add_library(${CataAnalyzerName} MODULE ${CataAnalyzerSrc})
target_link_libraries(${CataAnalyzerName} PRIVATE clangTidy)
endif ()

target_include_directories(${CataAnalyzerName} SYSTEM PRIVATE
Expand Down
4 changes: 4 additions & 0 deletions tools/clang-tidy-plugin/LargeStackObjectCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ static void CheckDecl( LargeStackObjectCheck &Check, const MatchFinder::MatchRes
return;
}

#if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR >= 17
if( std::optional<CharUnits> VarSize = Result.Context->getTypeSizeInCharsIfKnown( T ) ) {
#else
if( Optional<CharUnits> VarSize = Result.Context->getTypeSizeInCharsIfKnown( T ) ) {
#endif
int VarSize_KiB = *VarSize / CharUnits::fromQuantity( 1024 );

if( VarSize_KiB >= 100 ) {
Expand Down

0 comments on commit 78fa850

Please sign in to comment.