[PATCH] D22154: [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 12:17:19 PDT 2016
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.
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.
http://reviews.llvm.org/D22154
Files:
clang-tidy/ClangTidyOptions.cpp
clang-tidy/tool/ClangTidyMain.cpp
test/clang-tidy/list-checks.cpp
Index: test/clang-tidy/list-checks.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/list-checks.cpp
@@ -0,0 +1,5 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"
Index: clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -313,13 +313,19 @@
if (!PathList.empty()) {
FileName = PathList.front();
}
- ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+ SmallString<256> FilePath(FileName);
+ if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+ llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+ }
+ ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
std::vector<std::string> EnabledChecks = getCheckNames(EffectiveOptions);
if (ExplainConfig) {
//FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
- RawOptions = OptionsProvider->getRawOptions(FileName);
+ RawOptions = OptionsProvider->getRawOptions(FilePath);
for (const std::string &Check : EnabledChecks) {
for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
Index: clang-tidy/ClangTidyOptions.cpp
===================================================================
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -218,15 +218,6 @@
std::vector<OptionsSource>
FileOptionsProvider::getRawOptions(StringRef FileName) {
DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
- SmallString<256> FilePath(FileName);
-
- if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
- llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
- // FIXME: Figure out what to do.
- } else {
- FileName = FilePath;
- }
std::vector<OptionsSource> RawOptions =
DefaultOptionsProvider::getRawOptions(FileName);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22154.63282.patch
Type: text/x-patch
Size: 2414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160708/e3d0d22a/attachment.bin>
More information about the cfe-commits
mailing list