clang 10.0.0git

Namespaces | Functions | Variables
CompilationDatabase.cpp File Reference
`#include "clang/Tooling/CompilationDatabase.h"`
`#include "clang/Basic/Diagnostic.h"`
`#include "clang/Basic/DiagnosticIDs.h"`
`#include "clang/Basic/DiagnosticOptions.h"`
`#include "clang/Basic/LLVM.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/ArrayRef.h"`
`#include "llvm/ADT/IntrusiveRefCntPtr.h"`
`#include "llvm/ADT/STLExtras.h"`
`#include "llvm/ADT/SmallString.h"`
`#include "llvm/ADT/SmallVector.h"`
`#include "llvm/ADT/StringRef.h"`
`#include "llvm/Option/Arg.h"`
`#include "llvm/Support/Casting.h"`
`#include "llvm/Support/Compiler.h"`
`#include "llvm/Support/ErrorOr.h"`
`#include "llvm/Support/Host.h"`
`#include "llvm/Support/LineIterator.h"`
`#include "llvm/Support/MemoryBuffer.h"`
`#include "llvm/Support/Path.h"`
`#include "llvm/Support/raw_ostream.h"`
`#include <algorithm>`
`#include <cassert>`
`#include <cstring>`
`#include <iterator>`
`#include <memory>`
`#include <sstream>`
`#include <string>`
`#include <system_error>`
`#include <utility>`
`#include <vector>`
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< CompilationDatabase > | findCompilationDatabaseFromDirectory (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...
static CompilationDatabasePluginRegistry::Add< FixedCompilationDatabasePlugin > | X ("fixed-compilation-database", "Reads plain-text flags file")

## 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

Definition at line 82 of file CompilationDatabase.cpp.

References clang::tooling::CompilationDatabase::loadFromDirectory().

Referenced by clang::tooling::CompilationDatabase::autoDetectFromDirectory(), and clang::tooling::CompilationDatabase::autoDetectFromSource().

## ◆ 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] | Args | Args 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 260 of file CompilationDatabase.cpp.

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

Referenced by clang::tooling::FixedCompilationDatabase::loadFromCommandLine().

## ◆ X()

static CompilationDatabasePluginRegistry::Add<FixedCompilationDatabasePlugin> X | ( | "fixed-compilation-database" | ,
|  | "Reads plain-text flags file" |
| ) |  |
| static