[PATCH] D72940: Add a support for clang tidy to import another configurations files from .clang-tidy

2023-03-22 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood resigned from this revision.
LegalizeAdulthood added a comment.
This revision now requires review to proceed.
Herald added a reviewer: njames93.
Herald added a subscriber: PiotrZSL.
Herald added a project: All.

No action taken, removing myself as a reviewer


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72940/new/

https://reviews.llvm.org/D72940

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72940: Add a support for clang tidy to import another configurations files from .clang-tidy

2022-01-10 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood requested changes to this revision.
LegalizeAdulthood added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: carlosgalvezp.

Please upload a full context diff so that the changes can be properly viewed.  
Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72940/new/

https://reviews.llvm.org/D72940

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72940: Add a support for clang tidy to import another configurations files from .clang-tidy

2020-01-17 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Please upload the diff with full context 
. This would also need a test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72940/new/

https://reviews.llvm.org/D72940



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72940: Add a support for clang tidy to import another configurations files from .clang-tidy

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre created this revision.
ykfre added a reviewer: clang-tools-extra.
ykfre added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

add  ConfigurationsFilesToImport option - to make it possible to import another 
configurations files from .clang-tidy, So there will be no need
to duplicate anymore the configuration file among projects, and it will be 
possible to just point the configuration file to some config in a share.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72940

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/docs/clang-tidy/index.rst


Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -242,7 +242,9 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
+file. This file can also imports configuration from another configuration 
file,
+using ConfigurationsFilesToImport option.
+If any configuration options have a corresponding command-line
 option, command-line option takes precedence. The effective
 configuration can be inspected using -dump-config:
 
@@ -251,6 +253,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ConfigurationsFilesToImport: ['yaml1FilePath', 'yaml2FilePath']
   FormatStyle: none
   User:user
   CheckOptions:
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -73,6 +73,9 @@
   /// Output warnings from system headers matching \c HeaderFilterRegex.
   llvm::Optional SystemHeaders;
 
+  /// Clang tidy configurations files to import.
+  llvm::Optional> ConfigurationsFilesToImport;
+
   /// Format code around applied fixes with clang-format using this
   /// style.
   ///
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("ConfigurationsFilesToImport", 
Options.ConfigurationsFilesToImport);
   }
 };
 
@@ -325,12 +326,34 @@
 }
 
 llvm::ErrorOr parseConfiguration(StringRef Config) {
-  llvm::yaml::Input Input(Config);
-  ClangTidyOptions Options;
-  Input >> Options;
-  if (Input.error())
-return Input.error();
-  return Options;
+   ClangTidyOptions Options;
+   llvm::yaml::Input Input(Config);
+
+   Input >> Options;
+   if (Input.error())
+   return Input.error();
+   if (!Options.ConfigurationsFilesToImport.hasValue()) {
+   return Options;
+   }
+   for (const auto& file : *Options.ConfigurationsFilesToImport)
+   {
+   llvm::ErrorOr> Text = 
llvm::MemoryBuffer::getFile(file);
+if (std::error_code EC = Text.getError()) {
+llvm::errs() << "Can't read " << file << ": " << EC.message()
+<< "\n";
+return EC;
+}
+   Config = Text->get()->getBuffer();
+   auto ReturnedOptions = parseConfiguration(Config);
+   if (ReturnedOptions)
+   {
+   Options = ReturnedOptions->mergeWith(Options);
+   }
+   else {
+   return ReturnedOptions;
+   }
+   }
+   return Options;
 }
 
 std::string configurationAsText(const ClangTidyOptions ) {


Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -242,7 +242,9 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
+file. This file can also imports configuration from another configuration file,
+using ConfigurationsFilesToImport option.
+If any configuration options have a corresponding command-line
 option, command-line option takes precedence. The effective
 configuration can be inspected using -dump-config:
 
@@ -251,6 +253,7 @@