[PATCH] clang-modernize: Add SubprocessCompilationDatabase

Edwin Vane edwin.vane at intel.com
Fri Oct 11 06:55:34 PDT 2013


  Renamed SubprocessCompilationDatabase to SingleCompilationDatabase

  - Also improved tests to ensure -c as a compilation flag works with
    clang-modernize's -c option.

Hi tareqsiraj, arielbernal, Sarcasm,

http://llvm-reviews.chandlerc.com/D1877

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1877?vs=4784&id=4836#toc

Files:
  clang-modernize/Core/CMakeLists.txt
  clang-modernize/Core/SingleCompilationDatabase.cpp
  clang-modernize/Core/SubprocessCompilationDatabase.cpp
  clang-modernize/Core/SingleCompilationDatabase.h
  clang-modernize/Core/SubprocessCompilationDatabase.h
  clang-modernize/tool/ClangModernize.cpp
  test/clang-modernize/Core/SingleCompilationDatabaseTest.cpp
  test/clang-modernize/Core/SubprocessCompilationDatabaseTest.cpp

Index: clang-modernize/Core/CMakeLists.txt
===================================================================
--- clang-modernize/Core/CMakeLists.txt
+++ clang-modernize/Core/CMakeLists.txt
@@ -5,7 +5,7 @@
   IncludeExcludeInfo.cpp
   PerfSupport.cpp
   ReplacementHandling.cpp
-  SubprocessCompilationDatabase.cpp
+  SingleCompilationDatabase.cpp
   Transforms.cpp
   Transform.cpp
   )
Index: clang-modernize/Core/SingleCompilationDatabase.cpp
===================================================================
--- clang-modernize/Core/SingleCompilationDatabase.cpp
+++ clang-modernize/Core/SingleCompilationDatabase.cpp
@@ -1,4 +1,4 @@
-//===-- Core/SubprocessCompilationDatabase.cpp ----------------------------===//
+//===-- Core/SingleCompilationDatabase.cpp ----------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -9,33 +9,33 @@
 ///
 /// \file
 /// \brief This file provides implementations for the
-/// SubprocessCompilationDatabase class.
+/// SingleCompilationDatabase class.
 ///
 //===----------------------------------------------------------------------===//
 
-#include "Core/SubprocessCompilationDatabase.h"
+#include "Core/SingleCompilationDatabase.h"
 
 using namespace llvm;
 using namespace clang::tooling;
 
-SubprocessCompilationDatabase::SubprocessCompilationDatabase(
+SingleCompilationDatabase::SingleCompilationDatabase(
     StringRef Directory, ArrayRef<std::string> Command) {
 
   this->Command.Directory = Directory;
   this->Command.CommandLine.insert(this->Command.CommandLine.end(),
                                    Command.begin(), Command.end());
 }
 
 std::vector<CompileCommand>
-SubprocessCompilationDatabase::getCompileCommands(StringRef FilePath) const {
+SingleCompilationDatabase::getCompileCommands(StringRef FilePath) const {
   return std::vector<CompileCommand>(1, Command);
 }
 
-std::vector<std::string> SubprocessCompilationDatabase::getAllFiles() const {
+std::vector<std::string> SingleCompilationDatabase::getAllFiles() const {
   return std::vector<std::string>();
 }
 
 std::vector<CompileCommand>
-SubprocessCompilationDatabase::getAllCompileCommands() const {
+SingleCompilationDatabase::getAllCompileCommands() const {
   return std::vector<CompileCommand>();
 }
Index: clang-modernize/Core/SingleCompilationDatabase.h
===================================================================
--- clang-modernize/Core/SingleCompilationDatabase.h
+++ clang-modernize/Core/SingleCompilationDatabase.h
@@ -1,4 +1,4 @@
-//===-- Core/SubprocessCompilationDatabase.h --------------------*- C++ -*-===//
+//===-- Core/SingleCompilationDatabase.h --------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,26 +8,25 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// \brief This file defines the SubprocessCompilationDatabase class which
+/// \brief This file defines the SingleCompilationDatabase class which
 /// is similar to FixedCompilationDatabase but will not mangle the compilation
 /// command.
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef CLANG_MODERNIZE_SUBPROCESSCOMPILATIONDATABASE_H
-#define CLANG_MODERNIZE_SUBPROCESSCOMPILATIONDATABASE_H
+#ifndef CLANG_MODERNIZE_SINGLECOMPILATIONDATABASE_H
+#define CLANG_MODERNIZE_SINGLECOMPILATIONDATABASE_H
 
 #include "clang/Tooling/CompilationDatabase.h"
 
 /// \brief Represents a single command line passed from a parent clang-modernize
 /// process for compiling a single file.
 ///
 /// This class doesn't need to know the name of that one file.
-class SubprocessCompilationDatabase
-    : public clang::tooling::CompilationDatabase {
+class SingleCompilationDatabase : public clang::tooling::CompilationDatabase {
 public:
-  SubprocessCompilationDatabase(llvm::StringRef Directory,
-                                llvm::ArrayRef<std::string> Command);
+  SingleCompilationDatabase(llvm::StringRef Directory,
+                            llvm::ArrayRef<std::string> Command);
 
   /// \brief Returns the single compile command this database was built around.
   ///
@@ -53,4 +52,4 @@
   clang::tooling::CompileCommand Command;
 };
 
-#endif // CLANG_MODERNIZE_SUBPROCESSCOMPILATIONDATABASE_H
+#endif // CLANG_MODERNIZE_SINGLECOMPILATIONDATABASE_H
Index: clang-modernize/tool/ClangModernize.cpp
===================================================================
--- clang-modernize/tool/ClangModernize.cpp
+++ clang-modernize/tool/ClangModernize.cpp
@@ -17,7 +17,7 @@
 
 #include "Core/PerfSupport.h"
 #include "Core/ReplacementHandling.h"
-#include "Core/SubprocessCompilationDatabase.h"
+#include "Core/SingleCompilationDatabase.h"
 #include "Core/Transform.h"
 #include "Core/Transforms.h"
 #include "clang/Basic/Diagnostic.h"
@@ -260,7 +260,7 @@
 
 CompilationDatabase *createCompilations(std::string &ErrorMessage) {
   if (!SubCompileDir.empty() && SubCompileArgs.getNumOccurrences() > 0)
-    return new SubprocessCompilationDatabase(SubCompileDir, SubCompileArgs);
+    return new SingleCompilationDatabase(SubCompileDir, SubCompileArgs);
 
   // Auto-detect a compilation database from BuildPath.
   if (BuildPath.getNumOccurrences() > 0)
Index: test/clang-modernize/Core/SingleCompilationDatabaseTest.cpp
===================================================================
--- test/clang-modernize/Core/SingleCompilationDatabaseTest.cpp
+++ test/clang-modernize/Core/SingleCompilationDatabaseTest.cpp
@@ -1,13 +1,13 @@
 // First pass using a compilation database is a base line. The next pass using
-// -compile-command and -compile-dir, which should provide the same information
-// as provided with the compilation database, is the real test.
+// -c and -d, which should provide the same information as provided with the
+// compilation database, is the real test.
 //
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
 // RUN: sed -e 's#$(path)#%/T#' -e 's#$(file)#%/t.cpp#' %S/Inputs/compile_commands.json > %T/compile_commands.json
 // RUN: clang-modernize -p %T -loop-convert %t.cpp
 // RUN: FileCheck -input-file=%t.cpp %s
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-modernize -loop-convert %t.cpp -d %T -c /opt/clang-3.3/bin/clang++ -c -g -c -o -c output -c %/t.cpp -c -std=c++11 -c -DDOOUTPUT
+// RUN: clang-modernize -loop-convert %t.cpp -d %T -c /opt/clang-3.3/bin/clang++ -c -g -c -o -c output.o -c -c -c %/t.cpp -c -std=c++11 -c -DDOOUTPUT
 // RUN: FileCheck -input-file=%t.cpp %s
 
 void g(int);
@@ -22,4 +22,3 @@
 #endif
   }
 }
-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1877.2.patch
Type: text/x-patch
Size: 6579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131011/b473e559/attachment.bin>


More information about the cfe-commits mailing list