# Calculate format=diff merge(dev-qt/qt-creator)=>4.8,4.9
--- a/src/shared/clang/clang_installation.pri
+++ b/src/shared/clang/clang_installation.pri
@@ -150,16 +150,6 @@
 output = $$system($$llvm_config --version, lines)
 LLVM_VERSION = $$extractVersion($$output)
 
-!isEmpty(LLVM_VERSION) {
-    versionIsAtLeast($$LLVM_VERSION, 7, 0, 0): {
-        CLANGFORMAT_LIBS=-lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
-        win32:CLANGFORMAT_LIBS += -lversion
-    } else:versionIsAtLeast($$LLVM_VERSION, 6, 0, 0): {
-        CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
-        win32:CLANGFORMAT_LIBS += -lversion
-    }
-}
-
 isEmpty(LLVM_VERSION) {
     $$llvmWarningOrError(\
         "Cannot determine clang version. Set LLVM_INSTALL_DIR to build the Clang Code Model",\
@@ -210,6 +200,19 @@
         $$llvmWarningOrError("Cannot find Clang shared library in $$LLVM_LIBDIR")
     }
 
+    versionIsAtLeast($$LLVM_VERSION, 7, 0, 0): {
+        exists($${LLVM_LIBDIR}/libclangFormat.so*)|exists($${LLVM_LIBDIR}/libclangFormat.dylib) {
+            CLANGFORMAT_LIBS=-lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
+            win32:CLANGFORMAT_LIBS += -lversion
+        } else {
+            CLANGFORMAT_LIBS=-lclang-cpp
+            ALL_CLANG_LIBS=-lclang-cpp
+        }
+    } else:versionIsAtLeast($$LLVM_VERSION, 6, 0, 0): {
+        CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
+        win32:CLANGFORMAT_LIBS += -lversion
+    }
+
     !contains(QMAKE_DEFAULT_LIBDIRS, $$LLVM_LIBDIR): LIBCLANG_LIBS = -L$${LLVM_LIBDIR}
     LIBCLANG_LIBS += $${CLANG_LIB}
 
