This is an archive of the discontinued LLVM Phabricator instance.

Summary: Instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed by other APIs.
ClosedPublic

Authored by compositeprimes on Nov 3 2019, 9:41 PM.

Diff Detail

Event Timeline

compositeprimes created this revision.Nov 3 2019, 9:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2019, 9:41 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
alexfh requested changes to this revision.Dec 10 2019, 5:38 AM
alexfh added inline comments.
include/clang/Tooling/DiagnosticsYaml.h
75 ↗(On Diff #227644)

We should serialize the ranges too.

This revision now requires changes to proceed.Dec 10 2019, 5:38 AM

Updated to serialize the ranges in yaml. This required making a few abstractions around the representation of CharSourceRange.

compositeprimes marked an inline comment as done.Feb 14 2020, 12:28 PM

Thanks for the update!

Please upload patches with full context. That makes navigating the code much easier during reviews. See https://llvm.org/docs/Phabricator.html

A few more comments inline.

include/clang/Tooling/Core/Diagnostic.h
62–70 ↗(On Diff #244737)

Why is this needed? Shouldn't LLVM_YAML_IS_SEQUENCE_VECTOR be enough to allow for SmallVector<DiagnosticAssociatedRange, ...> to be yaml serializable? Seems to work with DiagnosticMessage and Diagnostic::Notes.

lib/Tooling/Core/Diagnostic.cpp
51 ↗(On Diff #244737)

With emplace_back constructor parameters can be used directly:

Ranges.emplace_back(Sources, Range);

That's the whole point of emplace_back.

compositeprimes marked 2 inline comments as done.

Removed unnecessary DiagnosticAssociatedRanges struct

Sorry about the lack of context on the last upload, this one should have it all

include/clang/Tooling/Core/Diagnostic.h
62–70 ↗(On Diff #244737)

Yeah, you're right it's not really needed. I had been trying to make it easier to convert a vector<CharSourceRange> to vector<AssociatedRange>, but it's really not that hard as is.

alexfh added inline comments.Feb 19 2020, 3:28 AM
include/clang/Tooling/Core/Diagnostic.h
51 ↗(On Diff #245207)

This comment was lost by Phabricator (or I just wanted to leave it without actually doing it?).

The name assumes a specific usage. I'd try to make it more generic in case there's another use case for the struct, for example: ByteRange (as opposed to TextRange, which would be {start line, start column, end line, end column}) or FileByteRange (if we want to stress that it contains a file name).

compositeprimes marked an inline comment as done.

Added tests for Yaml serialization

include/clang/Tooling/Core/Diagnostic.h
51 ↗(On Diff #245207)

Ah good idea, I like that name, Done

alexfh accepted this revision.Feb 21 2020, 9:32 AM

LG. Thanks!

Do you have commit rights or should someone help you committing the patch?

This revision is now accepted and ready to land.Feb 21 2020, 9:32 AM

I don't have commit rights (this is my first llvm commit!), so could someone help out? Thanks!

This revision was automatically updated to reflect the committed changes.

I don't have commit rights (this is my first llvm commit!), so could someone help out? Thanks!

Fixed include paths and a broken test and committed as b26c88e3c6e08f8f78ab4291bc85b5685241f493.

Next step is to plumb this to clang-tidy.