Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move llvm to 8.0.1 as llvm-lite was updated to 0.29 #5146

Merged
merged 7 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions codechecker-llvm8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
diff --git a/ClangTidy.h b/ClangTidy.h
index 0ea9a70..dc11200 100644
--- a/ClangTidy.h
+++ b/ClangTidy.h
@@ -230,12 +230,13 @@ getCheckOptions(const ClangTidyOptions &Options,
/// \param StoreCheckProfile If provided, and EnableCheckProfile is true,
/// the profile will not be output to stderr, but will instead be stored
/// as a JSON file in the specified directory.
-void runClangTidy(clang::tidy::ClangTidyContext &Context,
- const tooling::CompilationDatabase &Compilations,
- ArrayRef<std::string> InputFiles,
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS,
- bool EnableCheckProfile = false,
- llvm::StringRef StoreCheckProfile = StringRef());
+std::vector<ClangTidyError>
+runClangTidy(clang::tidy::ClangTidyContext &Context,
+ const tooling::CompilationDatabase &Compilations,
+ ArrayRef<std::string> InputFiles,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
+ bool EnableCheckProfile = false,
+ llvm::StringRef StoreCheckProfile = StringRef());

// FIXME: This interface will need to be significantly extended to be useful.
// FIXME: Implement confidence levels for displaying/fixing errors.
@@ -243,9 +244,10 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context,
/// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
/// Errors containing fixes are automatically applied and reformatted. If no
/// clang-format configuration file is found, the given \P FormatStyle is used.
-void handleErrors(ClangTidyContext &Context, bool Fix,
+void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
+ ClangTidyContext &Context, bool Fix,
unsigned &WarningsAsErrorsCount,
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS);
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);

/// \brief Serializes replacements into YAML and writes them to the specified
/// output stream.
diff --git a/ClangTidyDiagnosticConsumer.h b/ClangTidyDiagnosticConsumer.h
index ae25013..a868203 100644
--- a/ClangTidyDiagnosticConsumer.h
+++ b/ClangTidyDiagnosticConsumer.h
@@ -102,6 +102,12 @@ public:
/// \brief Initializes \c ClangTidyContext instance.
ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
bool AllowEnablingAnalyzerAlphaCheckers = false);
+ /// Sets the DiagnosticsEngine that diag() will emit diagnostics to.
+ // FIXME: this is required initialization, and should be a constructor param.
+ // Fix the context -> diag engine -> consumer -> context initialization cycle.
+ void setDiagnosticsEngine(DiagnosticsEngine *DiagEngine) {
+ this->DiagEngine = DiagEngine;
+ }

~ClangTidyContext();

@@ -160,12 +166,6 @@ public:
/// counters.
const ClangTidyStats &getStats() const { return Stats; }

- /// \brief Returns all collected errors.
- ArrayRef<ClangTidyError> getErrors() const { return Errors; }
-
- /// \brief Clears collected errors.
- void clearErrors() { Errors.clear(); }
-
/// \brief Control profile collection in clang-tidy.
void setEnableProfiling(bool Profile);
bool getEnableProfiling() const { return Profile; }
@@ -192,18 +192,9 @@ public:
}

private:
- // Calls setDiagnosticsEngine() and storeError().
+ // Writes to Stats.
friend class ClangTidyDiagnosticConsumer;
- friend class ClangTidyPluginAction;
-
- /// \brief Sets the \c DiagnosticsEngine so that Diagnostics can be generated
- /// correctly.
- void setDiagnosticsEngine(DiagnosticsEngine *Engine);

- /// \brief Store an \p Error.
- void storeError(const ClangTidyError &Error);
-
- std::vector<ClangTidyError> Errors;
DiagnosticsEngine *DiagEngine;
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider;

@@ -243,13 +234,12 @@ public:
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info) override;

- /// \brief Flushes the internal diagnostics buffer to the ClangTidyContext.
- void finish() override;
+ // Retrieve the diagnostics that were captured.
+ std::vector<ClangTidyError> take();

private:
void finalizeLastError();
-
- void removeIncompatibleErrors(SmallVectorImpl<ClangTidyError> &Errors) const;
+ void removeIncompatibleErrors();

/// \brief Returns the \c HeaderFilter constructed for the options set in the
/// context.
@@ -257,13 +247,12 @@ private:

/// \brief Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
/// according to the diagnostic \p Location.
- void checkFilters(SourceLocation Location);
+ void checkFilters(SourceLocation Location, const SourceManager& Sources);
bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;

ClangTidyContext &Context;
bool RemoveIncompatibleErrors;
- std::unique_ptr<DiagnosticsEngine> Diags;
- SmallVector<ClangTidyError, 8> Errors;
+ std::vector<ClangTidyError> Errors;
std::unique_ptr<llvm::Regex> HeaderFilter;
bool LastErrorRelatesToUserCode;
bool LastErrorPassesLineFilter;
diff --git a/ClangTidyOptions.h b/ClangTidyOptions.h
index b2a4ce4..3ea3538 100644
--- a/ClangTidyOptions.h
+++ b/ClangTidyOptions.h
@@ -15,7 +15,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/ErrorOr.h"
-#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/Support/VirtualFileSystem.h"
#include <functional>
#include <map>
#include <string>
@@ -221,7 +221,7 @@ public:
FileOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
const ClangTidyOptions &DefaultOptions,
const ClangTidyOptions &OverrideOptions,
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = nullptr);

/// \brief Initializes the \c FileOptionsProvider instance with a custom set
/// of configuration file handlers.
@@ -255,7 +255,7 @@ protected:
llvm::StringMap<OptionsSource> CachedOptions;
ClangTidyOptions OverrideOptions;
ConfigFileHandlers ConfigHandlers;
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS;
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
};

/// \brief Parses LineFilter from JSON and stores it to the \p Options.
diff --git a/tool/ClangTidyMain.cpp b/tool/ClangTidyMain.cpp
index f36c4ec..d72cf98 100644
--- a/tool/ClangTidyMain.cpp
+++ b/tool/ClangTidyMain.cpp
@@ -254,7 +254,7 @@ static void printStats(const ClangTidyStats &Stats) {
}

static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider(
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS) {
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
ClangTidyGlobalOptions GlobalOptions;
if (std::error_code Err = parseLineFilter(LineFilter, GlobalOptions)) {
llvm::errs() << "Invalid LineFilter: " << Err.message() << "\n\nUsage:\n";
@@ -302,7 +302,7 @@ static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider(
OverrideOptions, std::move(FS));
}

-llvm::IntrusiveRefCntPtr<vfs::FileSystem>
+llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
getVfsOverlayFromFile(const std::string &OverlayFile) {
llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFS(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
@@ -315,7 +315,7 @@ getVfsOverlayFromFile(const std::string &OverlayFile) {
return nullptr;
}

- IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getVFSFromYAML(
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = vfs::getVFSFromYAML(
std::move(Buffer.get()), /*DiagHandler*/ nullptr, OverlayFile);
if (!FS) {
llvm::errs() << "Error: invalid virtual filesystem overlay file '"
@@ -329,7 +329,7 @@ getVfsOverlayFromFile(const std::string &OverlayFile) {
static int clangTidyMain(int argc, const char **argv) {
CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
cl::ZeroOrMore);
- llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS(
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS(
VfsOverlay.empty() ? vfs::getRealFileSystem()
: getVfsOverlayFromFile(VfsOverlay));
if (!BaseFS)
@@ -421,9 +421,9 @@ static int clangTidyMain(int argc, const char **argv) {

ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
- runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
- EnableCheckProfile, ProfilePrefix);
- ArrayRef<ClangTidyError> Errors = Context.getErrors();
+ std::vector<ClangTidyError> Errors =
+ runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+ EnableCheckProfile, ProfilePrefix);
bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
}) != Errors.end();
@@ -433,7 +433,7 @@ static int clangTidyMain(int argc, const char **argv) {
unsigned WErrorCount = 0;

// -fix-errors implies -fix.
- handleErrors(Context, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+ handleErrors(Errors, Context, (FixErrors || Fix) && !DisableFixes, WErrorCount,
BaseFS);

if (!ExportFixes.empty() && !Errors.empty()) {
2 changes: 2 additions & 0 deletions codechecker.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ Source: git+https://github.com/%github_user/CMSCodeChecker.git?obj=%{branch}/%{t

BuildRequires: cmake
Requires: llvm
Patch0: codechecker-llvm8

%prep
%setup -n %n-%{realversion}
%patch0 -p1

%build
mkdir build
Expand Down
8 changes: 4 additions & 4 deletions llvm.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### RPM external llvm 7.1.0
### RPM external llvm 8.0.1
## INITENV +PATH LD_LIBRARY_PATH %{i}/lib64
## INITENV +PATH PYTHON27PATH %{i}/lib64/python`echo $PYTHON_VERSION | cut -d. -f 1,2`/site-packages
%define isamd64 %(case %{cmsplatf} in (*_amd64_*) echo 1 ;; (*) echo 0 ;; esac)
Expand All @@ -10,9 +10,9 @@ Requires: cuda
%endif
AutoReq: no

%define llvmCommit 5fe28f5b0bcb1e30ea1f26c647919db4978584e3
%define llvmBranch cms/release/7.x/llvmorg-7.1.0
%define iwyuCommit 7b8980310f98ea76ac6d4e703d8bd07bde3d8ebc
%define llvmCommit a0f653798ce2e441cabef0311f11f8fd2ce8b1f0
%define llvmBranch cms/release/8.x/635f8ff
%define iwyuCommit 4d2bbcc0d98faccfc51d15c6f6a573ec78d7751d
%define iwyuBranch master

Source0: git+https://github.com/cms-externals/llvm-project.git?obj=%{llvmBranch}/%{llvmCommit}&export=llvm-%{realversion}-%{llvmCommit}&module=llvm-%{realversion}-%{llvmCommit}&output=/llvm-%{realversion}-%{llvmCommit}.tgz
Expand Down
8 changes: 5 additions & 3 deletions pip/py2-llvmlite.file
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Requires: py2-enum34 llvm py2-wheel
%define source0 git+https://github.com/cms-externals/llvmlite?obj=cms/master/d5fadcc/432a75a3bdefee6e927196086d31a7eb0d92404d&export=llvmlite-%{realversion}&output=/source.tar.gz
%define PipPreBuild export LLVM_CONFIG=${LLVM_ROOT}/bin/llvm-config
%define doPython3 no
Requires: llvm py2-wheel py2-enum34
Patch0: py2-llvmlite-fpic-flag

%define PipPreBuild export LLVM_CONFIG=${LLVM_ROOT}/bin/llvm-config && tar -xzf llvmlite-%{realversion}.tar.gz && pushd llvmlite-%{realversion} && for pch in %{patches} ; do patch -p1 < ${pch} ; done && popd && rm -f llvmlite-%{realversion}.tar.gz && tar czf llvmlite-%{realversion}.tar.gz llvmlite-%{realversion}
13 changes: 13 additions & 0 deletions py2-dxr-dxrindex-fpic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dxr/plugins/clang/makefile b/dxr/plugins/clang/makefile
index b504c04..7f8fc29 100644
--- a/dxr/plugins/clang/makefile
+++ b/dxr/plugins/clang/makefile
@@ -12,7 +12,7 @@ LDFLAGS := $(LDFLAGS) -fPIC -g $(LLVM_LDFLAGS) -shared
build: libclang-index-plugin.so

%.o: %.cpp
- $(CXX) $(CXXFLAGS) -c $^ -o $@
+ $(CXX) $(CXXFLAGS) -fPIC -c $^ -o $@

libclang-index-plugin.so: dxr-index.o sha1.o
$(CXX) $(LDFLAGS) $^ -o $@
41 changes: 41 additions & 0 deletions py2-dxr-llvm801.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/dxr/plugins/clang/dxr-index.cpp b/dxr/plugins/clang/dxr-index.cpp
index 6b35340..bba5563 100644
--- a/dxr/plugins/clang/dxr-index.cpp
+++ b/dxr/plugins/clang/dxr-index.cpp
@@ -744,7 +744,7 @@ public:
}

bool VisitCallExpr(CallExpr *e) {
- if (!interestingLocation(e->getLocStart()))
+ if (!interestingLocation(e->getBeginLoc()))
return true;

Decl *callee = e->getCalleeDecl();
@@ -756,7 +756,7 @@ public:
// 1. callee isn't necessarily a function. Think function pointers.
// 2. We might not be in a function. Think global function decls
// 3. Virtual functions need not be called virtually!
- beginRecord("call", e->getLocStart());
+ beginRecord("call", e->getBeginLoc());
if (m_currentFunction) {
recordValue("callername", getQualifiedName(*m_currentFunction));
recordValue("callerloc", locationToString(m_currentFunction->getLocation()));
@@ -783,7 +783,7 @@ public:
}

bool VisitCXXConstructExpr(CXXConstructExpr *e) {
- if (!interestingLocation(e->getLocStart()))
+ if (!interestingLocation(e->getBeginLoc()))
return true;

CXXConstructorDecl *callee = e->getConstructor();
@@ -795,7 +795,7 @@ public:
// 1. callee isn't necessarily a function. Think function pointers.
// 2. We might not be in a function. Think global function decls
// 3. Virtual functions need not be called virtually!
- beginRecord("call", e->getLocStart());
+ beginRecord("call", e->getBeginLoc());
if (m_currentFunction) {
recordValue("callername", getQualifiedName(*m_currentFunction));
recordValue("callerloc", locationToString(m_currentFunction->getLocation()));

4 changes: 4 additions & 0 deletions py2-dxr.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Patch3: py2-dxr-clang36
Patch4: py2-dxr-sqlite38
Patch5: py2-dxr-clang37
Patch6: py2-dxr-clang700
Patch7: py2-dxr-llvm801
Patch8: py2-dxr-dxrindex-fpic
%define keep_archives true

%prep
Expand All @@ -31,6 +33,8 @@ cd ..
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
mv trilite-%triliteCommit/* trilite
%setup -T -D -n dxr-%dxrCommit

Expand Down
13 changes: 13 additions & 0 deletions py2-llvmlite-fpic-flag.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/ffi/Makefile.linux b/ffi/Makefile.linux
index 334e9ff..9501d2c 100644
--- a/ffi/Makefile.linux
+++ b/ffi/Makefile.linux
@@ -5,7 +5,7 @@ CXX ?= g++
CXX_FLTO_FLAGS ?= -flto
LD_FLTO_FLAGS ?= -flto -Wl,--exclude-libs=ALL

-CXXFLAGS = $(LLVM_CXXFLAGS) $(CXX_FLTO_FLAGS)
+CXXFLAGS = $(LLVM_CXXFLAGS) $(CXX_FLTO_FLAGS) -fPIC
LDFLAGS := $(LDFLAGS) $(LLVM_LDFLAGS) $(LD_FLTO_FLAGS)
LIBS = $(LLVM_LIBS)
INCLUDE = core.h