-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7862f70
commit 43c1509
Showing
5 changed files
with
296 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2023 Vinnie Falco ([email protected]) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdox | ||
// | ||
|
||
#ifndef MRDOX_TESTS_SINGLE_FILE_HPP | ||
#define MRDOX_TESTS_SINGLE_FILE_HPP | ||
|
||
#include <clang/Tooling/CompilationDatabase.h> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
/** Compilation database for a single .cpp file. | ||
*/ | ||
class SingleFile | ||
: public tooling::CompilationDatabase | ||
{ | ||
std::vector<tooling::CompileCommand> cc_; | ||
|
||
public: | ||
SingleFile( | ||
llvm::StringRef dir, | ||
llvm::StringRef file, | ||
llvm::StringRef output) | ||
{ | ||
std::vector<std::string> cmds; | ||
cmds.emplace_back("clang"); | ||
cmds.emplace_back(file); | ||
cc_.emplace_back( | ||
dir, | ||
file, | ||
std::move(cmds), | ||
output); | ||
cc_.back().Heuristic = "unit test"; | ||
} | ||
|
||
std::vector<tooling::CompileCommand> | ||
getCompileCommands( | ||
llvm::StringRef FilePath) const override | ||
{ | ||
if(! FilePath.equals(cc_.front().Filename)) | ||
return {}; | ||
return { cc_.front() }; | ||
} | ||
|
||
std::vector<std::string> | ||
getAllFiles() const override | ||
{ | ||
return { cc_.front().Filename }; | ||
} | ||
|
||
std::vector<tooling::CompileCommand> | ||
getAllCompileCommands() const override | ||
{ | ||
return { cc_.front() }; | ||
} | ||
}; | ||
|
||
} // mrdox | ||
} // clang | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.