Skip to content

Commit

Permalink
Rename ClangLazy.so to ClazyPlugin.so
Browse files Browse the repository at this point in the history
And renamed the actual plugin name from clang-clazy to clazy
  • Loading branch information
Sergio Martins committed Oct 24, 2018
1 parent 4c6c491 commit f559a06
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CMakeFiles/
CMakeCache.txt
CMakeLists.txt.user
ClangLazy.cbp
ClazyPlugin.cbp
cmake_install.cmake
lib/
compile.output
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The man page is not available on Windows.
#

project(ClangLazy)
project(clazy)

cmake_minimum_required(VERSION 3.3)
include(FeatureSummary)
Expand Down Expand Up @@ -134,13 +134,13 @@ endmacro()
set(SYMBOL_FILE Lazy.exports)

if (NOT CLAZY_BUILD_WITH_CLANG)
add_clang_plugin(ClangLazy ${CLAZY_PLUGIN_SRCS})
set_target_properties(ClangLazy PROPERTIES
add_clang_plugin(ClazyPlugin ${CLAZY_PLUGIN_SRCS})
set_target_properties(ClazyPlugin PROPERTIES
LINKER_LANGUAGE CXX
PREFIX ""
)

install(TARGETS ClangLazy
install(TARGETS ClazyPlugin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down Expand Up @@ -190,10 +190,10 @@ if (NOT CLAZY_BUILD_WITH_CLANG)
add_executable(clazy-standalone ${CLAZY_STANDALONE_SRCS})

if(MSVC)
# On MSVC clang-standalone crashes with a meaningless backtrace if linked to ClangLazy.dll
# On MSVC clang-standalone crashes with a meaningless backtrace if linked to ClazyPlugin.dll
target_link_libraries(clazy-standalone clangFrontend)
else()
target_link_libraries(clazy-standalone ClangLazy)
target_link_libraries(clazy-standalone ClazyPlugin)
endif()

link_to_llvm(clazy-standalone TRUE)
Expand Down
5 changes: 3 additions & 2 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- clazy-standalone executable. Allows to run clazy against a JSON compilation database
instead of as a plugin. clang-tidy doesn't support loading external modules (https://bugs.llvm.org/show_bug.cgi?id=32739)
so this is a good workaround.
- qt-compat mode. Allows to disable Qt5 specific checks by passing -Xclang -plugin-arg-clang-lazy -Xclang qt4-compat
- qt-compat mode. Allows to disable Qt5 specific checks by passing -Xclang -plugin-arg-clazy -Xclang qt4-compat
- New checks:
install-event-filter
qcolor-from-literal
Expand Down Expand Up @@ -94,4 +94,5 @@
* v1.5 (, 2019)
- New Checks:
ifndef-define-typo
- Removed support for the obscure -DCLAZY_BUILD_UTILS_LIB to simplify the CMakeLists.txt.
- Removed support for the obscure -DCLAZY_BUILD_UTILS_LIB to simplify the CMakeLists.txt
- Renamed the clazy plugin from ClangLazy.so to ClazyPlugin.so
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ You should now have the clazy command available to you, in `<prefix>/bin/`.
Compile your programs with it instead of clang++/g++.

Note that this command is just a convenience wrapper which calls:
`clang++ -Xclang -load -Xclang ClangLazy.so -Xclang -add-plugin -Xclang clang-lazy`
`clang++ -Xclang -load -Xclang ClazyPlugin.so -Xclang -add-plugin -Xclang clazy`

If you have multiple versions of clang installed (say clang++-3.8 and clang++-3.9)
you can choose which one to use by setting the CLANGXX environment variable, like so:
Expand All @@ -195,7 +195,7 @@ To make it the compiler for qmake projects, just run qmake like:
`qmake -spec linux-clang QMAKE_CXX="clazy"`

Alternatively, if you want to use clang directly, without the wrapper:
`qmake -spec linux-clang QMAKE_CXXFLAGS="-Xclang -load -Xclang ClangLazy.so -Xclang -add-plugin -Xclang clang-lazy"`
`qmake -spec linux-clang QMAKE_CXXFLAGS="-Xclang -load -Xclang ClazyPlugin.so -Xclang -add-plugin -Xclang clazy"`

You can also edit mkspecs/common/clang.conf and change QMAKE_CXX to clazy instead of clang++ and run qmake -spec linux-clang

Expand Down Expand Up @@ -317,7 +317,7 @@ export CLAZY_CHECKS="level0,no-qenums" # Enables all checks from level0, except
export CLAZY_CHECKS="level0,detaching-temporary" # Enables all from level0 and also detaching-temporary
```
## Example via compiler argument
`clazy -Xclang -plugin-arg-clang-lazy -Xclang level0,detaching-temporary`
`clazy -Xclang -plugin-arg-clazy -Xclang level0,detaching-temporary`
Don't forget to re-run cmake/qmake/etc if you altered the c++ flags to specify flags.

# clazy-standalone and JSON database support
Expand Down Expand Up @@ -370,7 +370,7 @@ For better results don't use parallel builds, otherwise a fixit being applied in

# Troubleshooting

- clang: symbol lookup error: `/usr/lib/x86_64-linux-gnu/ClangLazy.so: undefined symbol: _ZNK5clang15DeclarationName11getAsStringEv`.
- clang: symbol lookup error: `/usr/lib/x86_64-linux-gnu/ClazyPlugin.so: undefined symbol: _ZNK5clang15DeclarationName11getAsStringEv`.
This is due to mixing ABIs. Your clang/llvm was compiled with the [new gcc c++ ABI][1] but you compiled the clazy plugin with clang (which uses [the old ABI][2]).

The solution is to build the clazy plugin with gcc or use a distro which hasn't migrated to gcc5 ABI yet, such as archlinux.
Expand Down Expand Up @@ -402,7 +402,7 @@ For better results don't use parallel builds, otherwise a fixit being applied in
# Qt4 compatibility mode

When running on codebases that must still compile with Qt4, you can pass `--qt4compat`
(a convenience option equivalent to passing `-Xclang -plugin-arg-clang-lazy -Xclang qt4-compat`)
(a convenience option equivalent to passing `-Xclang -plugin-arg-clazy -Xclang qt4-compat`)
to disable checks that only make sense with Qt5.

For example, to build a CMake project with Qt4 compatibility use:
Expand Down
2 changes: 1 addition & 1 deletion clazy-cl.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
clang.exe --driver-mode=cl -Qunused-arguments -Xclang -load -Xclang ClangLazy.dll -Xclang -add-plugin -Xclang clang-lazy -Wno-microsoft-enum-value %*
clang.exe --driver-mode=cl -Qunused-arguments -Xclang -load -Xclang ClazyPlugin.dll -Xclang -add-plugin -Xclang clazy -Wno-microsoft-enum-value %*
2 changes: 1 addition & 1 deletion clazy.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
clang.exe -Qunused-arguments -Xclang -load -Xclang ClangLazy.dll -Xclang -add-plugin -Xclang clang-lazy %*
clang.exe -Qunused-arguments -Xclang -load -Xclang ClazyPlugin.dll -Xclang -add-plugin -Xclang clazy %*
18 changes: 9 additions & 9 deletions clazy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ HELP() {
echo
echo "Convenience Options:"
echo " --qt4compat Qt4 compatibility mode. useful for source code that can build with Qt4"
echo " (this is the same as passing \"-Xclang -plugin-arg-clang-lazy -Xclang qt4-compat\")"
echo " (this is the same as passing \"-Xclang -plugin-arg-clazy -Xclang qt4-compat\")"
echo " --qtdeveloper Special option for building Qt5 itself resulting in fewer false positives"
echo " (this is the same as passing \"-Xclang -plugin-arg-clang-lazy -Xclang qt-developer\")"
echo " (this is the same as passing \"-Xclang -plugin-arg-clazy -Xclang qt-developer\")"
echo
echo "All other options are passed directly to clang++ and handled from there."
echo
Expand Down Expand Up @@ -87,31 +87,31 @@ ExtraClangOptions=""
if ( test $# -gt 0 -a "$1" = "--qt4compat" )
then
shift
ExtraClangOptions="-Xclang -plugin-arg-clang-lazy -Xclang qt4-compat"
ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang qt4-compat"
fi
if ( test $# -gt 0 -a "$1" = "--qtdeveloper" )
then
shift
ExtraClangOptions="-Xclang -plugin-arg-clang-lazy -Xclang qt-developer"
ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang qt-developer"
fi
if ( test $# -gt 0 -a "$1" = "--visit-implicit-code" )
then
shift
ExtraClangOptions="-Xclang -plugin-arg-clang-lazy -Xclang visit-implicit-code"
ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang visit-implicit-code"
fi

ClangLazyLib=ClangLazy@CMAKE_SHARED_LIBRARY_SUFFIX@
ClazyPluginLib=ClazyPlugin@CMAKE_SHARED_LIBRARY_SUFFIX@

if ( test -f "$libdir/$ClangLazyLib" )
if ( test -f "$libdir/$ClazyPluginLib" )
then
# find plugin libraries in install dir
export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$libdir:$DYLD_LIBRARY_PATH
elif ( test -f "$(dirname $0)/lib/$ClangLazyLib" )
elif ( test -f "$(dirname $0)/lib/$ClazyPluginLib" )
then
# find plugin libraries in build dir
export LD_LIBRARY_PATH=$(dirname $0)/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$(dirname $0)/lib:$DYLD_LIBRARY_PATH
fi

${CLANGXX:-clang++} -Qunused-arguments -Xclang -load -Xclang $ClangLazyLib -Xclang -add-plugin -Xclang clang-lazy $ExtraClangOptions "$@"
${CLANGXX:-clang++} -Qunused-arguments -Xclang -load -Xclang $ClazyPluginLib -Xclang -add-plugin -Xclang clazy $ExtraClangOptions "$@"
2 changes: 1 addition & 1 deletion dev-scripts/make_windows_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def copy_files(work_dir):
copy("../README.md", PACKAGE_DIR + 'clazy/README-CLAZY.md')
copy(LLVM_INSTALL_DIR + '/bin/clang.exe', PACKAGE_DIR + 'clazy/bin/clang/')
copy(LLVM_INSTALL_DIR + '/bin/clang.exe', PACKAGE_DIR + 'clazy/bin/clang/clang-cl.exe')
copy(LLVM_INSTALL_DIR + '/bin/ClangLazy.dll', PACKAGE_DIR + 'clazy/bin/clang/')
copy(LLVM_INSTALL_DIR + '/bin/ClazyPlugin.dll', PACKAGE_DIR + 'clazy/bin/clang/')
copy(LLVM_INSTALL_DIR + '/bin/clazy-standalone.exe', PACKAGE_DIR + 'clazy/bin/clang/')

run_command("cp -r %s/lib/clang/ %s" % (LLVM_INSTALL_DIR, PACKAGE_DIR + 'clazy/bin/lib/'))
Expand Down
4 changes: 2 additions & 2 deletions docs/man/clazy.pod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Use this when your source code can build with Qt4 and Qt5 in order to easily
suppress issues that cannot be fixed due to the requirement of the Qt4 API.

This is a convenience option which is identical to directly passing:
"-Xclang -plugin-arg-clang-lazy -Xclang qt4-compat"
"-Xclang -plugin-arg-clazy -Xclang qt4-compat"

=back

Expand All @@ -66,7 +66,7 @@ B<For Qt developers only.> This option is special for running clazy on Qt itsel
Will result in fewer false positives being reported in Qt code.

This is a convenience option which is identical to directly passing:
"-Xclang -plugin-arg-clang-lazy -Xclang qt-developer"
"-Xclang -plugin-arg-clazy -Xclang qt-developer"

=back

Expand Down
4 changes: 2 additions & 2 deletions src/Clazy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void ClazyASTAction::PrintHelp(llvm::raw_ostream &ros) const
ros << " export CLAZY_CHECKS=\"level0,reserve-candidates,qstring-allocations\"\n";
ros << " export CLAZY_CHECKS=\"reserve-candidates\"\n\n";
ros << "or pass as compiler arguments, for example:\n";
ros << " -Xclang -plugin-arg-clang-lazy -Xclang reserve-candidates,qstring-allocations\n";
ros << " -Xclang -plugin-arg-clazy -Xclang reserve-candidates,qstring-allocations\n";
ros << "\n";
ros << "To enable FixIts for a check, also set the env variable CLAZY_FIXIT, for example:\n";
ros << " export CLAZY_FIXIT=\"fix-qlatin1string-allocations\"\n\n";
Expand Down Expand Up @@ -398,4 +398,4 @@ unique_ptr<ASTConsumer> ClazyStandaloneASTAction::CreateASTConsumer(CompilerInst
volatile int ClazyPluginAnchorSource = 0;

static FrontendPluginRegistry::Add<ClazyASTAction>
X("clang-lazy", "clang lazy plugin");
X("clazy", "clang lazy plugin");
28 changes: 14 additions & 14 deletions tests/clazy/test_requested_checks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
unset CLAZY_CHECKS
unset CLAZY_FIXIT
CLAZY_COMMAND="clazy -c -o /dev/null -xc++ -Xclang -plugin-arg-clang-lazy -Xclang print-requested-checks "
CLAZY_COMMAND="clazy -c -o /dev/null -xc++ -Xclang -plugin-arg-clazy -Xclang print-requested-checks "
CLAZY_COMMAND_STDIN=$CLAZY_COMMAND"-"

# Test without checks:
Expand Down Expand Up @@ -46,28 +46,28 @@ unset CLAZY_FIXIT
unset CLAZY_CHECKS

# Test specifying check in command line
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts -)

# Pass two checks in command line
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,foreach -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,foreach -)

# Pass fixits through the command-line
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang fix-old-style-connect -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang fix-old-style-connect -)

# Pass level0
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang level0 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang level0 -)

# Pass level1
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang level1 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang level1 -)

# Pass level0 + another check
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang reserve-candidates -Xclang -plugin-arg-clang-lazy -Xclang level0 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang reserve-candidates -Xclang -plugin-arg-clazy -Xclang level0 -)

# Pass level0 + another check that's already in level0
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang qdatetime-utc -Xclang -plugin-arg-clang-lazy -Xclang level0 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang qdatetime-utc -Xclang -plugin-arg-clazy -Xclang level0 -)

# Use a level argument in the checks list
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,foreach,level0 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,foreach,level0 -)

# Use a level in env-variable
export CLAZY_CHECKS="level1"
Expand All @@ -84,16 +84,16 @@ echo | $CLAZY_COMMAND_STDIN

# Use both env variable and compiler argument
export CLAZY_CHECKS="level0,reserve-candidates"
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,level0 -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,level0 -)

unset CLAZY_FIXIT
unset CLAZY_CHECKS

# Test disabling checks works
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,foreach,no-foreach -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,no-foreach -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang implicit-casts,no-implicit-casts -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clang-lazy -Xclang level0,no-qenums,no-qgetenv -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,foreach,no-foreach -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,no-foreach -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang implicit-casts,no-implicit-casts -)
echo | $($CLAZY_COMMAND -Xclang -plugin-arg-clazy -Xclang level0,no-qenums,no-qgetenv -)

# Test disabling checks works, now with env variables
export CLAZY_CHECKS="implicit-casts,foreach,no-foreach"
Expand Down
2 changes: 1 addition & 1 deletion tests/clazy/test_requested_checks.sh.expected
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ To specify which checks to enable set the CLAZY_CHECKS env variable, for example
export CLAZY_CHECKS="reserve-candidates"

or pass as compiler arguments, for example:
-Xclang -plugin-arg-clang-lazy -Xclang reserve-candidates,qstring-allocations
-Xclang -plugin-arg-clazy -Xclang reserve-candidates,qstring-allocations

To enable FixIts for a check, also set the env variable CLAZY_FIXIT, for example:
export CLAZY_FIXIT="fix-qlatin1string-allocations"
Expand Down
20 changes: 10 additions & 10 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ def find_qt_installation(major_version, qmakes):

def libraryName():
if _platform == 'win32':
return 'ClangLazy.dll'
return 'ClazyPlugin.dll'
elif _platform == 'darwin':
return 'ClangLazy.dylib'
return 'ClazyPlugin.dylib'
else:
return 'ClangLazy.so'
return 'ClazyPlugin.so'

def link_flags():
flags = "-lQt5Core -lQt5Gui -lQt5Widgets"
Expand All @@ -214,7 +214,7 @@ def clazy_cpp_args():
return "-Wno-unused-value -Qunused-arguments -std=c++14 "

def more_clazy_args():
return " -Xclang -plugin-arg-clang-lazy -Xclang no-inplace-fixits " + clazy_cpp_args()
return " -Xclang -plugin-arg-clazy -Xclang no-inplace-fixits " + clazy_cpp_args()

def clazy_standalone_command(test, qt):
result = " -- " + clazy_cpp_args() + qt.compiler_flags() + " " + test.flags
Expand Down Expand Up @@ -248,23 +248,23 @@ def clazy_command(qt, test, filename):
result = os.environ['CLAZY_CXX'] + more_clazy_args() + qt.compiler_flags()
else:
clang = os.getenv('CLANGXX', 'clang')
result = clang + " -Xclang -load -Xclang " + libraryName() + " -Xclang -add-plugin -Xclang clang-lazy " + more_clazy_args() + qt.compiler_flags()
result = clang + " -Xclang -load -Xclang " + libraryName() + " -Xclang -add-plugin -Xclang clazy " + more_clazy_args() + qt.compiler_flags()

if test.qt4compat:
result = result + " -Xclang -plugin-arg-clang-lazy -Xclang qt4-compat "
result = result + " -Xclang -plugin-arg-clazy -Xclang qt4-compat "

if test.only_qt:
result = result + " -Xclang -plugin-arg-clang-lazy -Xclang only-qt "
result = result + " -Xclang -plugin-arg-clazy -Xclang only-qt "

if test.qt_developer:
result = result + " -Xclang -plugin-arg-clang-lazy -Xclang qt-developer "
result = result + " -Xclang -plugin-arg-clazy -Xclang qt-developer "

if test.link and _platform.startswith('linux'): # Linking on one platform is enough. Won't waste time on macOS and Windows.
result = result + " " + link_flags()
else:
result = result + " -c "

result = result + test.flags + " -Xclang -plugin-arg-clang-lazy -Xclang " + string.join(test.checks, ',') + " "
result = result + test.flags + " -Xclang -plugin-arg-clazy -Xclang " + string.join(test.checks, ',') + " "
if not test.isFixedFile: # When compiling the already fixed file disable fixit, we don't want to fix twice
result += _enable_fixits_argument + " "
result += filename
Expand Down Expand Up @@ -311,7 +311,7 @@ def compiler_name():
#-------------------------------------------------------------------------------
# Global variables

_enable_fixits_argument = "-Xclang -plugin-arg-clang-lazy -Xclang enable-all-fixits"
_enable_fixits_argument = "-Xclang -plugin-arg-clazy -Xclang enable-all-fixits"
_dump_ast = args.dump_ast
_verbose = args.verbose
_no_standalone = args.no_standalone
Expand Down
2 changes: 1 addition & 1 deletion windows-package/clazy-cl.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
"%~dp0\clang\clang.exe" --driver-mode=cl -Qunused-arguments -Xclang -load -Xclang ClangLazy.dll -Xclang -add-plugin -Xclang clang-lazy -Wno-microsoft-enum-value %*
"%~dp0\clang\clang.exe" --driver-mode=cl -Qunused-arguments -Xclang -load -Xclang ClazyPlugin.dll -Xclang -add-plugin -Xclang clazy -Wno-microsoft-enum-value %*
2 changes: 1 addition & 1 deletion windows-package/clazy.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
"%~dp0\clang\clang.exe" -Qunused-arguments -Xclang -load -Xclang ClangLazy.dll -Xclang -add-plugin -Xclang clang-lazy %*
"%~dp0\clang\clang.exe" -Qunused-arguments -Xclang -load -Xclang ClazyPlugin.dll -Xclang -add-plugin -Xclang clazy %*

0 comments on commit f559a06

Please sign in to comment.