~pali/llvm/clang-tools-extra-3.9

« back to all changes in this revision

Viewing changes to clang-tidy/tool/ClangTidyMain.cpp

  • Committer: hokein
  • Date: 2016-07-11 07:47:04 UTC
  • Revision ID: svn-v4:91177308-0d34-0410-b5e6-96231b3b80d8:clang-tools-extra/trunk:275051
[clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

Summary:
Although there is no guarantee of getOptions/getRawOptions receiving an
absolute path, we try to make it if possible. So FileOptionProvider subclasses
don't have to convert the path to an absolute path.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D22154

Show diffs side-by-side

added added

removed removed

Lines of Context:
313
313
  if (!PathList.empty()) {
314
314
    FileName = PathList.front();
315
315
  }
316
 
  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
 
316
 
 
317
  SmallString<256> FilePath(FileName);
 
318
  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
 
319
    llvm::errs() << "Can't make absolute path from " << FileName << ": "
 
320
                 << EC.message() << "\n";
 
321
  }
 
322
  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
317
323
  std::vector<std::string> EnabledChecks = getCheckNames(EffectiveOptions);
318
324
 
319
325
  if (ExplainConfig) {
320
326
    //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
321
327
    std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
322
 
        RawOptions = OptionsProvider->getRawOptions(FileName);
 
328
        RawOptions = OptionsProvider->getRawOptions(FilePath);
323
329
    for (const std::string &Check : EnabledChecks) {
324
330
      for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
325
331
        if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {