[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

Hugo Gonzalez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 17 08:36:36 PDT 2018


hugoeg added inline comments.


================
Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:20
+
+bool IsInAbseilFile(const SourceManager& manager, SourceLocation loc){
+  if (loc.isInvalid()) {
----------------
hokein wrote:
> I think we can make it as an ASTMatcher instead of a function like:
> 
> ```
> AST_POLYMORPHIC_MATCHER_P(isInAbseilFile,
>                           AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc)) {
>    // your code here.
> }
> ```
Unfortunately, I do not think we can.  That was the way I originally tried to implement it. It worked on no-namespace-check, but not in this one. This is because as an AST_POLYMORPHIC_MATCHER_P, we are trying to match an usage of a Decl, not the Decl itself and since we are matching a TypeLoc in no-internal-deps-check, not really the usage, it doesn't work.

As a result, I modified my original implementation, which you will see in no-namespace-check and turned it into IsInAbseilFile(SourceManager&,  SourceLocation), which is just takes a source location and returns whether the location we matched is in an Abseil file


https://reviews.llvm.org/D50542





More information about the cfe-commits mailing list