[llvm] 5ffd940 - Reland [FileCheck] Move FileCheck implementation out of LLVMSupport into its own library
Raphael Isemann via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 06:00:41 PDT 2020
Author: Raphael Isemann
Date: 2020-09-01T14:59:28+02:00
New Revision: 5ffd940ac02a8e000691c45a6dc4f69d0198e675
URL: https://github.com/llvm/llvm-project/commit/5ffd940ac02a8e000691c45a6dc4f69d0198e675
DIFF: https://github.com/llvm/llvm-project/commit/5ffd940ac02a8e000691c45a6dc4f69d0198e675.diff
LOG: Reland [FileCheck] Move FileCheck implementation out of LLVMSupport into its own library
This relands e9a3d1a401b07cbf7b11695637f1b549782a26cd which was originally
missing linking LLVMSupport into LLMVFileCheck which broke the SHARED_LIBS build.
Original summary:
The actual FileCheck logic seems to be implemented in LLVMSupport. I don't see a
good reason for having FileCheck implemented there as it has a very specific use
while LLVMSupport is a dependency of pretty much every LLVM tool there is. In
fact, the only use of FileCheck I could find (outside the FileCheck tool and the
FileCheck unit test) is a single call in GISelMITest.h.
This moves the FileCheck logic to its own LLVMFileCheck library. This way only
FileCheck and the GlobalISelTests now have a dependency on this code.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D86344
Added:
llvm/include/llvm/FileCheck/FileCheck.h
llvm/lib/FileCheck/CMakeLists.txt
llvm/lib/FileCheck/FileCheck.cpp
llvm/lib/FileCheck/FileCheckImpl.h
llvm/unittests/FileCheck/CMakeLists.txt
llvm/unittests/FileCheck/FileCheckTest.cpp
llvm/utils/gn/secondary/llvm/lib/FileCheck/BUILD.gn
llvm/utils/gn/secondary/llvm/unittests/FileCheck/BUILD.gn
Modified:
llvm/include/llvm/module.modulemap
llvm/lib/CMakeLists.txt
llvm/lib/Support/CMakeLists.txt
llvm/unittests/CMakeLists.txt
llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
llvm/unittests/Support/CMakeLists.txt
llvm/utils/FileCheck/CMakeLists.txt
llvm/utils/FileCheck/FileCheck.cpp
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
llvm/utils/gn/secondary/llvm/unittests/CodeGen/GlobalISel/BUILD.gn
llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
Removed:
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/lib/Support/FileCheckImpl.h
llvm/unittests/Support/FileCheckTest.cpp
################################################################################
diff --git a/llvm/include/llvm/Support/FileCheck.h b/llvm/include/llvm/FileCheck/FileCheck.h
similarity index 97%
rename from llvm/include/llvm/Support/FileCheck.h
rename to llvm/include/llvm/FileCheck/FileCheck.h
index 1eb609ef725e..f9fd3d72f888 100644
--- a/llvm/include/llvm/Support/FileCheck.h
+++ b/llvm/include/llvm/FileCheck/FileCheck.h
@@ -1,4 +1,4 @@
-//==-- llvm/Support/FileCheck.h ---------------------------*- C++ -*-==//
+//==-- llvm/FileCheck/FileCheck.h --------------------------------*- C++ -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_SUPPORT_FILECHECK_H
-#define LLVM_SUPPORT_FILECHECK_H
+#ifndef LLVM_FILECHECK_FILECHECK_H
+#define LLVM_FILECHECK_FILECHECK_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
diff --git a/llvm/include/llvm/module.modulemap b/llvm/include/llvm/module.modulemap
index 0ce3574e9b0d..22959c62fc81 100644
--- a/llvm/include/llvm/module.modulemap
+++ b/llvm/include/llvm/module.modulemap
@@ -195,6 +195,13 @@ module LLVM_ExecutionEngine {
}
+module LLVM_FileCheck {
+ requires cplusplus
+
+ umbrella "FileCheck"
+ module * { export * }
+}
+
// Orc utilities that don't depend only on Support (not ExecutionEngine or
// IR). This is a workaround for ExecutionEngine's broken layering, and will
// be removed in the future.
diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 35d204d7d63e..851b89bb95f0 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -3,6 +3,7 @@
add_subdirectory(IR)
add_subdirectory(FuzzMutate)
+add_subdirectory(FileCheck)
add_subdirectory(InterfaceStub)
add_subdirectory(IRReader)
add_subdirectory(CodeGen)
diff --git a/llvm/lib/FileCheck/CMakeLists.txt b/llvm/lib/FileCheck/CMakeLists.txt
new file mode 100644
index 000000000000..91c80e1482f1
--- /dev/null
+++ b/llvm/lib/FileCheck/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_llvm_component_library(LLVMFileCheck
+ FileCheck.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ "${LLVM_MAIN_INCLUDE_DIR}/llvm/FileCheck"
+)
+
+target_link_libraries(LLVMFileCheck LLVMSupport)
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
similarity index 99%
rename from llvm/lib/Support/FileCheck.cpp
rename to llvm/lib/FileCheck/FileCheck.cpp
index 0cc3a2d73925..a0371cf88b3c 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -13,7 +13,7 @@
// as well as various unittests.
//===----------------------------------------------------------------------===//
-#include "llvm/Support/FileCheck.h"
+#include "llvm/FileCheck/FileCheck.h"
#include "FileCheckImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSet.h"
diff --git a/llvm/lib/Support/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h
similarity index 99%
rename from llvm/lib/Support/FileCheckImpl.h
rename to llvm/lib/FileCheck/FileCheckImpl.h
index 7cdeb7c766fd..05b2a529002f 100644
--- a/llvm/lib/Support/FileCheckImpl.h
+++ b/llvm/lib/FileCheck/FileCheckImpl.h
@@ -12,13 +12,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_SUPPORT_FILECHECKIMPL_H
-#define LLVM_LIB_SUPPORT_FILECHECKIMPL_H
+#ifndef LLVM_LIB_FILECHECK_FILECHECKIMPL_H
+#define LLVM_LIB_FILECHECK_FILECHECKIMPL_H
-#include "llvm/Support/FileCheck.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/FileCheck/FileCheck.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/SourceMgr.h"
#include <map>
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 5e0d43b148d6..9eefea566fee 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -134,7 +134,6 @@ add_llvm_component_library(LLVMSupport
Error.cpp
ErrorHandling.cpp
ExtensibleRTTI.cpp
- FileCheck.cpp
FileCollector.cpp
FileUtilities.cpp
FileOutputBuffer.cpp
diff --git a/llvm/unittests/CMakeLists.txt b/llvm/unittests/CMakeLists.txt
index 850bc14b207f..4076642a217e 100644
--- a/llvm/unittests/CMakeLists.txt
+++ b/llvm/unittests/CMakeLists.txt
@@ -24,6 +24,7 @@ add_subdirectory(CodeGen)
add_subdirectory(DebugInfo)
add_subdirectory(Demangle)
add_subdirectory(ExecutionEngine)
+add_subdirectory(FileCheck)
add_subdirectory(Frontend)
add_subdirectory(FuzzMutate)
add_subdirectory(InterfaceStub)
diff --git a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
index 7ca77b98dc08..4b278217f738 100644
--- a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
CodeGen
Core
+ FileCheck
GlobalISel
MC
MIRParser
diff --git a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
index db3f2b9531c9..336915ce8651 100644
--- a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
+++ b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
@@ -21,8 +21,8 @@
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
+#include "llvm/FileCheck/FileCheck.h"
#include "llvm/InitializePasses.h"
-#include "llvm/Support/FileCheck.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
diff --git a/llvm/unittests/FileCheck/CMakeLists.txt b/llvm/unittests/FileCheck/CMakeLists.txt
new file mode 100644
index 000000000000..7fe4f0c009d0
--- /dev/null
+++ b/llvm/unittests/FileCheck/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+ FileCheck
+ Support
+)
+
+add_llvm_unittest(FileCheckTests
+ FileCheckTest.cpp
+)
+
+target_link_libraries(FileCheckTests PRIVATE LLVMTestingSupport)
diff --git a/llvm/unittests/Support/FileCheckTest.cpp b/llvm/unittests/FileCheck/FileCheckTest.cpp
similarity index 99%
rename from llvm/unittests/Support/FileCheckTest.cpp
rename to llvm/unittests/FileCheck/FileCheckTest.cpp
index e986c434c551..c5eaa5fb04d2 100644
--- a/llvm/unittests/Support/FileCheckTest.cpp
+++ b/llvm/unittests/FileCheck/FileCheckTest.cpp
@@ -1,4 +1,4 @@
-//===- llvm/unittest/Support/FileCheckTest.cpp - FileCheck tests --===//
+//===- llvm/unittest/FileCheck/FileCheckTest.cpp - FileCheck tests --------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/FileCheck.h"
-#include "../lib/Support/FileCheckImpl.h"
+#include "llvm/FileCheck/FileCheck.h"
+#include "../lib/FileCheck/FileCheckImpl.h"
#include "llvm/Support/Regex.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt
index 19fabfe2c74b..30de294f499e 100644
--- a/llvm/unittests/Support/CMakeLists.txt
+++ b/llvm/unittests/Support/CMakeLists.txt
@@ -33,7 +33,6 @@ add_llvm_unittest(SupportTests
ErrorOrTest.cpp
ErrorTest.cpp
ExtensibleRTTITest.cpp
- FileCheckTest.cpp
FileCollectorTest.cpp
FileOutputBufferTest.cpp
FileUtilitiesTest.cpp
diff --git a/llvm/utils/FileCheck/CMakeLists.txt b/llvm/utils/FileCheck/CMakeLists.txt
index 32e948a1a19e..d17034323178 100644
--- a/llvm/utils/FileCheck/CMakeLists.txt
+++ b/llvm/utils/FileCheck/CMakeLists.txt
@@ -2,4 +2,4 @@ add_llvm_utility(FileCheck
FileCheck.cpp
)
-target_link_libraries(FileCheck PRIVATE LLVMSupport)
+target_link_libraries(FileCheck PRIVATE LLVMFileCheck LLVMSupport)
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 81889b2540f9..66b0a9776aaa 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -15,12 +15,12 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/FileCheck/FileCheck.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/FileCheck.h"
#include <cmath>
using namespace llvm;
diff --git a/llvm/utils/gn/secondary/llvm/lib/FileCheck/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/FileCheck/BUILD.gn
new file mode 100644
index 000000000000..af211df351a3
--- /dev/null
+++ b/llvm/utils/gn/secondary/llvm/lib/FileCheck/BUILD.gn
@@ -0,0 +1,7 @@
+static_library("FileCheck") {
+ output_name = "LLVMFileCheck"
+ deps = [ "//llvm/lib/Support" ]
+ sources = [
+ "FileCheck.cpp",
+ ]
+}
diff --git a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
index 93270c20243a..150847aa9b05 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -71,7 +71,6 @@ static_library("Support") {
"Error.cpp",
"ErrorHandling.cpp",
"ExtensibleRTTI.cpp",
- "FileCheck.cpp",
"FileCollector.cpp",
"FileOutputBuffer.cpp",
"FileUtilities.cpp",
diff --git a/llvm/utils/gn/secondary/llvm/unittests/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
index 5a235671e5c8..ae233fd7bde6 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
@@ -20,6 +20,7 @@ group("unittests") {
"ExecutionEngine/JITLink:JITLinkTests",
"ExecutionEngine/MCJIT:MCJITTests",
"ExecutionEngine/Orc:OrcJITTests",
+ "FileCheck:FileCheckTests",
"Frontend:LLVMFrontendTests",
"FuzzMutate:FuzzMutateTests",
"IR:IRTests",
diff --git a/llvm/utils/gn/secondary/llvm/unittests/CodeGen/GlobalISel/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/CodeGen/GlobalISel/BUILD.gn
index 5104716bccdd..7933f8c70782 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/CodeGen/GlobalISel/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/CodeGen/GlobalISel/BUILD.gn
@@ -5,6 +5,7 @@ unittest("GlobalISelTests") {
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/GlobalISel",
"//llvm/lib/CodeGen/MIRParser",
+ "//llvm/lib/FileCheck",
"//llvm/lib/IR",
"//llvm/lib/MC",
"//llvm/lib/Support",
diff --git a/llvm/utils/gn/secondary/llvm/unittests/FileCheck/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/FileCheck/BUILD.gn
new file mode 100644
index 000000000000..85eef061d225
--- /dev/null
+++ b/llvm/utils/gn/secondary/llvm/unittests/FileCheck/BUILD.gn
@@ -0,0 +1,9 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("FileCheckTests") {
+ deps = [
+ "//llvm/lib/FileCheck",
+ "//llvm/lib/Support",
+ ]
+ sources = [ "FileCheckTest.cpp" ]
+}
diff --git a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
index be757feb2e9e..f47e5a996b33 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
@@ -36,7 +36,6 @@ unittest("SupportTests") {
"ErrorOrTest.cpp",
"ErrorTest.cpp",
"ExtensibleRTTITest.cpp",
- "FileCheckTest.cpp",
"FileCollectorTest.cpp",
"FileOutputBufferTest.cpp",
"FileUtilitiesTest.cpp",
More information about the llvm-commits
mailing list