Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #645 from vkalintiris/origin/fix-clang-plugin-args
Browse files Browse the repository at this point in the history
Pick the source directory specified last in the command line.
  • Loading branch information
erikrose committed Mar 29, 2017
2 parents 403a4ed + 5c3e2eb commit d286f55
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dxr/plugins/clang/dxr-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ class DXRIndexAction : public PluginASTAction {

bool ParseArgs(const CompilerInstance &CI,
const std::vector<std::string>& args) override {
if (args.size() != 1) {
if (args.empty()) {
DiagnosticsEngine &D = CI.getDiagnostics();
unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
"Need an argument for the source directory");
Expand All @@ -1399,8 +1399,10 @@ class DXRIndexAction : public PluginASTAction {
}
// Load our directories.

// The source directory.
char *abs_src = realpath(args[0].c_str(), nullptr);
// The source directory. Follow the GCC/Clang convention of picking the
// the value of the argument that has been specificed last in the command
// line.
char *abs_src = realpath(args.back().c_str(), nullptr);
if (!abs_src) {
DiagnosticsEngine &D = CI.getDiagnostics();
unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
Expand Down

0 comments on commit d286f55

Please sign in to comment.