@@ -525,6 +525,31 @@ static bool verifyFileExtensions(
525
525
return AnyInvalid;
526
526
}
527
527
528
+ static SmallString<256 > makeAbsolute (llvm::StringRef Input) {
529
+ if (Input.empty ())
530
+ return {};
531
+ SmallString<256 > AbsolutePath (Input);
532
+ if (std::error_code EC = llvm::sys::fs::make_absolute (AbsolutePath)) {
533
+ llvm::errs () << " Can't make absolute path from " << Input << " : "
534
+ << EC.message () << " \n " ;
535
+ }
536
+ return AbsolutePath;
537
+ }
538
+
539
+ static llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> createBaseFS () {
540
+ llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> BaseFS (
541
+ new vfs::OverlayFileSystem (vfs::getRealFileSystem ()));
542
+
543
+ if (!VfsOverlay.empty ()) {
544
+ IntrusiveRefCntPtr<vfs::FileSystem> VfsFromFile =
545
+ getVfsFromFile (VfsOverlay, BaseFS);
546
+ if (!VfsFromFile)
547
+ return nullptr ;
548
+ BaseFS->pushOverlay (std::move (VfsFromFile));
549
+ }
550
+ return BaseFS;
551
+ }
552
+
528
553
int clangTidyMain (int argc, const char **argv) {
529
554
llvm::InitLLVM X (argc, argv);
530
555
@@ -540,44 +565,26 @@ int clangTidyMain(int argc, const char **argv) {
540
565
return 1 ;
541
566
}
542
567
543
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> BaseFS (
544
- new vfs::OverlayFileSystem (vfs::getRealFileSystem ()));
545
-
546
- if (!VfsOverlay.empty ()) {
547
- IntrusiveRefCntPtr<vfs::FileSystem> VfsFromFile =
548
- getVfsFromFile (VfsOverlay, BaseFS);
549
- if (!VfsFromFile)
550
- return 1 ;
551
- BaseFS->pushOverlay (std::move (VfsFromFile));
552
- }
568
+ llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> BaseFS = createBaseFS ();
569
+ if (!BaseFS)
570
+ return 1 ;
553
571
554
572
auto OwningOptionsProvider = createOptionsProvider (BaseFS);
555
573
auto *OptionsProvider = OwningOptionsProvider.get ();
556
574
if (!OptionsProvider)
557
575
return 1 ;
558
576
559
- auto MakeAbsolute = [](const std::string &Input) -> SmallString<256 > {
560
- if (Input.empty ())
561
- return {};
562
- SmallString<256 > AbsolutePath (Input);
563
- if (std::error_code EC = llvm::sys::fs::make_absolute (AbsolutePath)) {
564
- llvm::errs () << " Can't make absolute path from " << Input << " : "
565
- << EC.message () << " \n " ;
566
- }
567
- return AbsolutePath;
568
- };
569
-
570
- SmallString<256 > ProfilePrefix = MakeAbsolute (StoreCheckProfile);
577
+ SmallString<256 > ProfilePrefix = makeAbsolute (StoreCheckProfile);
571
578
572
579
StringRef FileName (" dummy" );
573
580
auto PathList = OptionsParser->getSourcePathList ();
574
581
if (!PathList.empty ()) {
575
582
FileName = PathList.front ();
576
583
}
577
584
578
- SmallString<256 > FilePath = MakeAbsolute (std::string (FileName));
579
-
585
+ SmallString<256 > FilePath = makeAbsolute (FileName);
580
586
ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions (FilePath);
587
+
581
588
std::vector<std::string> EnabledChecks =
582
589
getCheckNames (EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
583
590
0 commit comments