Skip to content

Commit 77dc05b

Browse files
[clang-doc] Fix use of source-root flag
The value, if any, of --source-root flag was not being used. This has been fixed and the logic was moved to the ClangDocContext contructor. Differential revision: https://reviews.llvm.org/D66268 llvm-svn: 369065
1 parent 6d6babf commit 77dc05b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,12 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
257257
std::vector<std::string> UserStylesheets,
258258
std::vector<std::string> JsScripts)
259259
: ECtx(ECtx), PublicOnly(PublicOnly), OutDirectory(OutDirectory),
260-
SourceRoot(SourceRoot), UserStylesheets(UserStylesheets),
261-
JsScripts(JsScripts) {
260+
UserStylesheets(UserStylesheets), JsScripts(JsScripts) {
261+
llvm::SmallString<128> SourceRootDir(SourceRoot);
262+
if (SourceRoot.empty())
263+
// If no SourceRoot was provided the current path is used as the default
264+
llvm::sys::fs::current_path(SourceRootDir);
265+
this->SourceRoot = SourceRootDir.str();
262266
if (!RepositoryUrl.empty()) {
263267
this->RepositoryUrl = RepositoryUrl;
264268
if (!RepositoryUrl.empty() && RepositoryUrl.find("http://") != 0 &&

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,11 @@ int main(int argc, const char **argv) {
203203
tooling::ArgumentInsertPosition::END),
204204
ArgAdjuster);
205205

206-
llvm::SmallString<128> SourceRootDir;
207-
// Check if the --source-root flag has a value
208-
if (SourceRoot.empty())
209-
// If it's empty the current path is used as the default
210-
llvm::sys::fs::current_path(SourceRootDir);
211-
212206
clang::doc::ClangDocContext CDCtx = {
213207
Exec->get()->getExecutionContext(),
214208
PublicOnly,
215209
OutDirectory,
216-
SourceRootDir.str(),
210+
SourceRoot,
217211
RepositoryUrl,
218212
{UserStylesheets.begin(), UserStylesheets.end()},
219213
{"index.js", "index_json.js"}};

0 commit comments

Comments
 (0)