clang  6.0.0svn
Namespaces | Functions | Variables
CompilationDatabase.cpp File Reference
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Job.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Tooling/CompilationDatabasePluginRegistry.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Option/Arg.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <sstream>
#include <system_error>
Include dependency graph for CompilationDatabase.cpp:

Go to the source code of this file.

Namespaces

 clang
 Dataflow Directional Tag Classes.
 
 clang::tooling
 

Functions

static std::unique_ptr< CompilationDatabasefindCompilationDatabaseFromDirectory (StringRef Directory, std::string &ErrorMessage)
 
static bool stripPositionalArgs (std::vector< const char *> Args, std::vector< std::string > &Result, std::string &ErrorMsg)
 Strips any positional args and possible argv[0] from a command-line provided by the user to construct a FixedCompilationDatabase. More...
 

Variables

volatile int clang::tooling::JSONAnchorSource = 0
 
static int LLVM_ATTRIBUTE_UNUSED clang::tooling::JSONAnchorDest = JSONAnchorSource
 

Function Documentation

◆ findCompilationDatabaseFromDirectory()

static std::unique_ptr<CompilationDatabase> findCompilationDatabaseFromDirectory ( StringRef  Directory,
std::string &  ErrorMessage 
)
static

◆ stripPositionalArgs()

static bool stripPositionalArgs ( std::vector< const char *>  Args,
std::vector< std::string > &  Result,
std::string &  ErrorMsg 
)
static

Strips any positional args and possible argv[0] from a command-line provided by the user to construct a FixedCompilationDatabase.

FixedCompilationDatabase requires a command line to be in this format as it constructs the command line for each file by appending the name of the file to be compiled. FixedCompilationDatabase also adds its own argv[0] to the start of the command line although its value is not important as it's just ignored by the Driver invoked by the ClangTool using the FixedCompilationDatabase.

FIXME: This functionality should probably be made available by clang::driver::Driver although what the interface should look like is not clear.

Parameters
[in]ArgsArgs as provided by the user.
Returns
Resulting stripped command line.
  • true if successful.
  • false if Args cannot be used for compilation jobs (e.g. contains an option like -E or -version).

Definition at line 206 of file CompilationDatabase.cpp.

References clang::driver::Action::AssembleJobClass, clang::driver::Action::CompileJobClass, End, and clang::driver::JobList::getJobs().