QTCREATORBUG-15157_Link-with-clazy.patch 6.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
diff --git a/lib/Transforms/CMakeLists.txt b/lib/Transforms/CMakeLists.txt
index 67bdeb27212..7fcddb15904 100644
--- a/lib/Transforms/CMakeLists.txt
+++ b/lib/Transforms/CMakeLists.txt
@@ -4,6 +4,5 @@ add_subdirectory(InstCombine)
 add_subdirectory(Scalar)
 add_subdirectory(IPO)
 add_subdirectory(Vectorize)
-add_subdirectory(Hello)
 add_subdirectory(ObjCARC)
 add_subdirectory(Coroutines)
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 124f0c72fd7..fdff2ffe6d4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -29,7 +29,6 @@ endif()
 set(LLVM_TEST_DEPENDS
           BugpointPasses
           FileCheck
-          LLVMHello
           UnitTests
           bugpoint
           count
diff --git a/tools/clang/tools/libclang/CMakeLists.txt b/tools/clang/tools/libclang/CMakeLists.txt
index 2dd6703076..2ef48266ac 100644
--- a/tools/clang/tools/libclang/CMakeLists.txt
+++ b/tools/clang/tools/libclang/CMakeLists.txt
@@ -19,6 +19,7 @@ set(SOURCES
   CXString.cpp
   CXType.cpp
   Indexing.cpp
+  LinkClazy.cpp
 
   ADDITIONAL_HEADERS
   CIndexDiagnostic.h
@@ -53,6 +54,14 @@ if (TARGET clangTidyPlugin)
   list(APPEND LIBS clangIncludeFixerPlugin)
 endif ()
 
+option(CLANG_ENABLE_CLAZY "Build libclang with clazy" OFF)
+
+if (CLANG_ENABLE_CLAZY)
+  add_definitions(-DENABLE_CLAZY)
+  link_directories(${CMAKE_INSTALL_PREFIX}/lib)
+  list(APPEND LIBS ClangLazy clangRewriteFrontend)
+endif()
+
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)
diff --git a/tools/clang/tools/libclang/LinkClazy.cpp b/tools/clang/tools/libclang/LinkClazy.cpp
new file mode 100644
--- /dev/null
+++ b/tools/clang/tools/libclang/LinkClazy.cpp
@@ -0,0 +1,78 @@
+#ifdef ENABLE_CLAZY
+extern volatile int ClazyPluginAnchorSource;
+static int ClazyPluginAnchorDestination = ClazyPluginAnchorSource;
+
+#define REGISTER_CHECK_WITH_FLAGS(CHECK_NAME, CLASS_NAME, LEVEL, OPTIONS) \
+    extern volatile int ClazyAnchor_##CLASS_NAME; \
+    volatile int ClazyAnchorDestination_##CLASS_NAME = ClazyAnchor_##CLASS_NAME;
+#define REGISTER_CHECK(CHECK_NAME, CLASS_NAME, LEVEL) \
+    extern volatile int ClazyAnchor_##CLASS_NAME; \
+    static int ClazyAnchorDestination_##CLASS_NAME = ClazyAnchor_##CLASS_NAME;
+
+REGISTER_CHECK("inefficient-qlist", InefficientQList, HiddenCheckLevel)
+REGISTER_CHECK("isempty-vs-count", IsEmptyVSCount, HiddenCheckLevel)
+REGISTER_CHECK(s_checkName, Qt4_QStringFromArray, HiddenCheckLevel)
+REGISTER_CHECK("tr-non-literal", TrNonLiteral, HiddenCheckLevel)
+REGISTER_CHECK("connect-non-signal", ConnectNonSignal, CheckLevel0)
+REGISTER_CHECK("connect-not-normalized", ConnectNotNormalized, CheckLevel0)
+REGISTER_CHECK("container-anti-pattern", ContainerAntiPattern, CheckLevel0)
+REGISTER_CHECK("lambda-in-connect", LambdaInConnect, CheckLevel0)
+REGISTER_CHECK("mutable-container-key", MutableContainerKey, CheckLevel0)
+REGISTER_CHECK("qcolor-from-literal", QColorFromLiteral, CheckLevel0)
+REGISTER_CHECK(s_checkName, QDateTimeUtc, CheckLevel0)
+REGISTER_CHECK_WITH_FLAGS("qenums", Qenums, CheckLevel0, RegisteredCheck::Option_Qt4Incompatible)
+REGISTER_CHECK("qfileinfo-exists", QFileInfoExists, CheckLevel0)
+REGISTER_CHECK_WITH_FLAGS(s_checkName, QGetEnv, CheckLevel0, RegisteredCheck::Option_Qt4Incompatible)
+REGISTER_CHECK("qmap-with-pointer-key", QMapWithPointerKey, CheckLevel0)
+REGISTER_CHECK("qstring-insensitive-allocation", QStringInsensitiveAllocation, CheckLevel0)
+REGISTER_CHECK("qstring-arg", StringArg, CheckLevel0)
+REGISTER_CHECK(s_checkName, StringRefCandidates, CheckLevel0)
+REGISTER_CHECK("qt-macros", QtMacros, CheckLevel0)
+REGISTER_CHECK("qvariant-template-instantiation", QVariantTemplateInstantiation, CheckLevel0)
+REGISTER_CHECK("strict-iterators", StrictIterators, CheckLevel0)
+REGISTER_CHECK("temporary-iterator", TemporaryIterator, CheckLevel0)
+REGISTER_CHECK("unused-non-trivial-variable", UnusedNonTrivialVariable, CheckLevel0)
+REGISTER_CHECK("writing-to-temporary", WritingToTemporary, CheckLevel0)
+REGISTER_CHECK("wrong-qglobalstatic", WrongQGlobalStatic, CheckLevel0)
+REGISTER_CHECK(s_checkName, AutoUnexpectedQStringBuilder, CheckLevel1)
+REGISTER_CHECK("child-event-qobject-cast", ChildEvent_qobject_cast, CheckLevel1)
+REGISTER_CHECK("connect-3arg-lambda", Connect3argLambda, CheckLevel1)
+REGISTER_CHECK("const-signal-or-slot", ConstSignalOrSlot, CheckLevel1)
+REGISTER_CHECK("ctor-missing-parent-argument", CtorMissingParentArgument, CheckLevel2)
+REGISTER_CHECK("detaching-temporary", DetachingTemporary, CheckLevel1)
+REGISTER_CHECK("foreach", Foreach, CheckLevel1)
+REGISTER_CHECK("incorrect-emit", IncorrectEmit, CheckLevel1)
+REGISTER_CHECK("inefficient-qlist-soft", InefficientQListSoft, CheckLevel1)
+REGISTER_CHECK("install-event-filter", InstallEventFilter, CheckLevel1)
+REGISTER_CHECK("non-pod-global-static", NonPodStatic, CheckLevel1)
+REGISTER_CHECK("overridden-signal", OverriddenSignal, CheckLevel1)
+REGISTER_CHECK("post-event", PostEvent, CheckLevel1)
+REGISTER_CHECK("qdeleteall", QDeleteAll, CheckLevel1)
+REGISTER_CHECK("qhash-namespace", qhash_namespace, CheckLevel1)
+REGISTER_CHECK("qlatin1string-non-ascii", QLatin1StringNonAscii, CheckLevel1)
+REGISTER_CHECK("qproperty-without-notify", QPropertyWithoutNotify, CheckLevel1)
+REGISTER_CHECK("qstring-left", QStringLeft, CheckLevel1)
+REGISTER_CHECK("range-loop", RangeLoop, CheckLevel1)
+REGISTER_CHECK("returning-data-from-temporary", ReturningDataFromTemporary, CheckLevel1)
+REGISTER_CHECK("rule-of-two-soft", RuleOfTwoSoft, CheckLevel1)
+REGISTER_CHECK("virtual-signal", VirtualSignal, CheckLevel1)
+REGISTER_CHECK("base-class-event", BaseClassEvent, CheckLevel2)
+REGISTER_CHECK("container-inside-loop", ContainerInsideLoop, CheckLevel2)
+REGISTER_CHECK("copyable-polymorphic", CopyablePolymorphic, CheckLevel2)
+REGISTER_CHECK(s_checkName, FunctionArgsByRef, CheckLevel2)
+REGISTER_CHECK("function-args-by-value", FunctionArgsByValue, CheckLevel2)
+REGISTER_CHECK("global-const-char-pointer", GlobalConstCharPointer, CheckLevel2)
+REGISTER_CHECK("implicit-casts", ImplicitCasts, CheckLevel2)
+REGISTER_CHECK("missing-qobject-macro", MissingQ_OBJECT, CheckLevel2)
+REGISTER_CHECK("missing-typeinfo", MissingTypeinfo, CheckLevel2)
+REGISTER_CHECK_WITH_FLAGS(s_checkName, OldStyleConnect, CheckLevel2, RegisteredCheck::Option_Qt4Incompatible)
+REGISTER_CHECK_WITH_FLAGS(s_checkName, QStringAllocations, CheckLevel2, RegisteredCheck::Option_Qt4Incompatible)
+REGISTER_CHECK("reserve-candidates", ReserveCandidates, CheckLevel2)
+REGISTER_CHECK("returning-void-expression", ReturningVoidExpression, CheckLevel2)
+REGISTER_CHECK("rule-of-three", RuleOfThree, CheckLevel2)
+REGISTER_CHECK("virtual-call-ctor", VirtualCallsFromCTOR, CheckLevel2)
+REGISTER_CHECK("assert-with-side-effects", AssertWithSideEffects, CheckLevel3)
+REGISTER_CHECK("detaching-member", DetachingMember, CheckLevel3)
+REGISTER_CHECK("bogus-dynamic-cast", BogusDynamicCast, CheckLevel3)
+REGISTER_CHECK("thread-with-slots", ThreadWithSlots, CheckLevel3)
+#endif