[PATCH] D157011: [Clang][Tooling] Accept preprocessed input files

2023-08-08 Thread J. Ryan Stinnett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG241cceb9af84: [Clang][Tooling] Accept preprocessed input 
files (authored by jryans).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157011/new/

https://reviews.llvm.org/D157011

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", "-c",
+"test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", "-c",
+"test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157011: [Clang][Tooling] Accept preprocessed input files

2023-08-06 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157011/new/

https://reviews.llvm.org/D157011

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157011: [Clang][Tooling] Accept preprocessed input files

2023-08-04 Thread J. Ryan Stinnett via Phabricator via cfe-commits
jryans updated this revision to Diff 547159.
jryans added a comment.

- Fixed formatting
- Rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157011/new/

https://reviews.llvm.org/D157011

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", "-c",
+"test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", "-c",
+"test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157011: [Clang][Tooling] Accept preprocessed input files

2023-08-03 Thread J. Ryan Stinnett via Phabricator via cfe-commits
jryans created this revision.
Herald added a project: All.
jryans added reviewers: dexonsmith, jansvoboda11.
jryans added a project: clang.
jryans published this revision for review.
Herald added a subscriber: cfe-commits.

This restores the tooling library's ability to accept invocations that take a
preprocessed file as the primary input.

Regressed by https://reviews.llvm.org/D105695
Fixes https://github.com/llvm/llvm-project/issues/63941


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157011

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -449,6 +449,13 @@
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 
+TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) {
+  addFile("test.i", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","test.i"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
 TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -147,6 +147,13 @@
 if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile))
   CC1Jobs.push_back();
 
+  // If there are no jobs for source files, try checking again for a single job
+  // with any file type. This accepts a preprocessed file as input.
+  if (CC1Jobs.empty())
+for (const driver::Command  : Jobs)
+  if (IsCC1Command(Job))
+CC1Jobs.push_back();
+
   if (CC1Jobs.empty() ||
   (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) {
 SmallString<256> error_msg;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits