[llvm-branch-commits] [cfe-branch] r148548 - in /cfe/branches/tooling: include/clang/Tooling/Tooling.h lib/Tooling/Tooling.cpp

Manuel Klimek klimek at google.com
Fri Jan 20 08:33:42 PST 2012


Author: klimek
Date: Fri Jan 20 10:33:42 2012
New Revision: 148548

URL: http://llvm.org/viewvc/llvm-project?rev=148548&view=rev
Log:
Minor tweaks.
- Adapts comments to conform to the style guide.
- Uses the binary name which was handed in for driver creation. 


Modified:
    cfe/branches/tooling/include/clang/Tooling/Tooling.h
    cfe/branches/tooling/lib/Tooling/Tooling.cpp

Modified: cfe/branches/tooling/include/clang/Tooling/Tooling.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Tooling/Tooling.h?rev=148548&r1=148547&r2=148548&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Tooling/Tooling.h (original)
+++ cfe/branches/tooling/include/clang/Tooling/Tooling.h Fri Jan 20 10:33:42 2012
@@ -35,13 +35,14 @@
 
 namespace tooling {
 
-/// Interface to generate clang::FrontendActions.
+/// \brief Interface to generate clang::FrontendActions.
 class FrontendActionFactory {
 public:
   virtual ~FrontendActionFactory();
 
-  /// Returns a new clang::FrontendAction. The caller takes ownership of the
-  /// returned action.
+  /// \brief Returns a new clang::FrontendAction.
+  ///
+  /// The caller takes ownership of the returned action.
   virtual clang::FrontendAction *New() = 0;
 };
 
@@ -55,7 +56,7 @@
 template <typename T>
 FrontendActionFactory *NewFrontendActionFactory();
 
-/// \brief Returns a new FrontendActionFactory any type that provides an
+/// \brief Returns a new FrontendActionFactory for any type that provides an
 /// implementation of NewFrontendAction().
 ///
 /// FactoryT must implement: FrontendAction *NewFrontendAction().
@@ -93,6 +94,10 @@
 
 /// \brief Converts a JSON escaped command line to a vector of arguments.
 ///
+/// Note that for performance reasons this escapes both the JSON escape layer
+/// and the command line escape layer at the same time with a single pass over
+/// the string.
+///
 /// \param JsonEscapedCommandLine The escaped command line as a string. This
 /// is assumed to be escaped as a JSON string (e.g. " and \ are escaped).
 /// In addition, any arguments containing spaces are assumed to be \-escaped.

Modified: cfe/branches/tooling/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Tooling/Tooling.cpp?rev=148548&r1=148547&r2=148548&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Tooling/Tooling.cpp (original)
+++ cfe/branches/tooling/lib/Tooling/Tooling.cpp Fri Jan 20 10:33:42 2012
@@ -44,26 +44,19 @@
 // code that sets up a compiler to run tools on it, and we should refactor
 // it to be based on the same framework.
 
-// Exists solely for the purpose of lookup of the main executable.
-static int StaticSymbol;
-
 /// \brief Builds a clang driver initialized for running clang tools.
 static clang::driver::Driver *NewDriver(clang::DiagnosticsEngine *Diagnostics,
                                         const char *BinaryName) {
-  // This just needs to be some symbol in the binary.
-  void *const SymbolAddr = &StaticSymbol;
-  const llvm::sys::Path ExePath =
-      llvm::sys::Path::GetMainExecutable(BinaryName, SymbolAddr);
-
   const std::string DefaultOutputName = "a.out";
   clang::driver::Driver *CompilerDriver = new clang::driver::Driver(
-      ExePath.str(), llvm::sys::getDefaultTargetTriple(),
+      BinaryName, llvm::sys::getDefaultTargetTriple(),
       DefaultOutputName, false, *Diagnostics);
   CompilerDriver->setTitle("clang_based_tool");
   return CompilerDriver;
 }
 
 /// \brief Retrieves the clang CC1 specific flags out of the compilation's jobs.
+///
 /// Returns NULL on error.
 static const clang::driver::ArgStringList *GetCC1Arguments(
     clang::DiagnosticsEngine *Diagnostics,
@@ -135,8 +128,10 @@
 
 namespace {
 
-// A parser for JSON escaped strings of command line arguments with \-escaping
-// for quoted arguments (see the documentation of UnescapeJsonCommandLine(...)).
+/// \brief A parser for JSON escaped strings of command line arguments.
+///
+/// Assumes \-escaping for quoted arguments (see the documentation of
+/// UnescapeJsonCommandLine(...)).
 class CommandLineArgumentParser {
  public:
   CommandLineArgumentParser(llvm::StringRef CommandLine)
@@ -283,7 +278,9 @@
 }
 
 /// \brief Returns the absolute path of 'File', by prepending it with
-/// 'BaseDirectory' if 'File' is not absolute. Otherwise returns 'File'.
+/// 'BaseDirectory' if 'File' is not absolute.
+///
+/// Otherwise returns 'File'.
 /// If 'File' starts with "./", the returned path will not contain the "./".
 /// Otherwise, the returned path will contain the literal path-concatenation of
 /// 'BaseDirectory' and 'File'.
@@ -343,6 +340,9 @@
                        Invocation.take(), *CC1Args, ToolAction.take());
 }
 
+// Exists solely for the purpose of lookup of the resource path.
+static int StaticSymbol;
+
 bool ToolInvocation::RunInvocation(
     const char *BinaryName,
     clang::driver::Compilation *Compilation,





More information about the llvm-branch-commits mailing list