This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix check for Abseil internal namespace access
ClosedPublic

Authored by rogeeff on Jan 9 2020, 2:47 PM.

Details

Summary

This change makes following modifications:

  • If reference originated from macro expansion, we report location inside of the macro instead of location where macro is referenced
  • If for any reason deduced location is not correct we silently ignore it.

Diff Detail

Event Timeline

rogeeff created this revision.Jan 9 2020, 2:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2020, 2:47 PM
Herald added a subscriber: mgehre. · View Herald Transcript

Should be change mentioned in Release Notes?

clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
40

Please don't use auto when type is not spelled in statement or iterator. Does variable name comply to LLVM Coding Guidelines?

Eugene.Zelenko retitled this revision from Fix clang-tidy check for Abseil internal namespace access to [clang-tidy] Fix check for Abseil internal namespace access.Jan 9 2020, 2:53 PM
Eugene.Zelenko added a project: Restricted Project.
rogeeff updated this revision to Diff 237225.Jan 9 2020, 4:49 PM

Please mark fixed comments as done.

rogeeff marked an inline comment as done.Jan 10 2020, 12:16 PM
mgehre removed a subscriber: mgehre.Jan 10 2020, 3:02 PM

It is my first time submitting clang-tidy change. So I'm not sure of the procedure exactly. Do we wait for something from me?

It is my first time submitting clang-tidy change. So I'm not sure of the procedure exactly. Do we wait for something from me?

Reviewers should make comments and finally approve patch when everything would be fine. Please keep in mind that people may be busy in real life.

lebedev.ri added inline comments.
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

Is there test coverage for this? When does/can this happen?

rogeeff marked 2 inline comments as done.Jan 13 2020, 9:20 AM
rogeeff added inline comments.
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

At the time when I wrote this internally the test cases in abseil-no-internal-dependencies.cpp were reproducing this failure. I'm not sure this is still the case. It is possible compiler was fixed since then.

aaron.ballman added inline comments.Jan 16 2020, 6:40 AM
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

I am not certain I'm following along (sorry if I'm just being dense). Are you saying that the existing test coverage in abseil-no-internal-dependencies.cpp was failing for you internally, and that's the reason for this fix? Or are you saying that the newly-added test cases in this patch were triggering this failure?

rogeeff marked 3 inline comments as done.Jan 16 2020, 10:29 AM
rogeeff added inline comments.
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

Newly added test cases were triggering the failure.

EricWF accepted this revision.Jan 17 2020, 10:38 AM

LGTM.

The weird template test case might is derived from an old failure that I believe was addressed in Clang, but regression tests are fine by me.
The macro expansion fix is correct and correctly tested.

clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

@lebedev.ri This also happened when the source location was inside a macro expansion. Which is solved by getting the spelling loc, and there is a test case that covers it.

This revision is now accepted and ready to land.Jan 17 2020, 10:38 AM
aaron.ballman accepted this revision.Jan 17 2020, 10:47 AM

LGTM

clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
43–44

Newly added test cases were triggering the failure.

Thanks for the clarification!