Looks like this:
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp | ||
---|---|---|
96 | IIUC, this places properties on the current HTML element as attributes, just like the built-in attributes that we add for other purposes (e.g. "value_id", "kind").
Suggestion: Can we nest all properties inside of a "properties" attribute? Edit: Having looked at the HTML template now, I see that we exclude certain attributes there ('kind', 'value_id', 'type', 'location') when listing properties. I still think naming conflicts are a potential problem though. I think it would also be clearer to explicitly pick the properties out of a properties attribute rather than excluding a blocklist of attributes. | |
121–123 | ||
122 | Same rationale as for properties above: can we nest the fields inside of a fields attribute? I think it would also be useful to distinguish between properties and fields in the HTML output; probably not with another nesting level (yikes!), but just rendered differently. This could easily be done if they were separated into properties and fields attributes. | |
149 | ||
clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp | ||
179 | Can you add some additional tests for the following?
Ideally, other value kinds too (see copy-paste error above for BiconditionalValue). |
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp | ||
---|---|---|
96 | Right, the data model is: a value (really, a Value/StorageLocation mashed together) is just a bag of attributes. I don't think making it more complicated is an improvement: being built-in isn't the same thing as being custom-rendered. Namespace conflict could be a problem: the current behavior is that the last value wins (per JS rules). I had this in the prototype, but dropped them because they seemed a bit ugly and conflicts unlikely in practice. WDYT? | |
121–123 | this is neat but capturing the structured binding Val is a C++20 feature | |
149 | right, thanks :-( | |
clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp | ||
179 | There isn't a reasonable way to test in that level of detail without paying a lot for it. If we restructure to allow such assertions on the JSON:
My experience is that not having proper tests for these kind of tools is the least-worst option: better than brittle tests where true vs spurious errors are unclear, and better than expensive+still incomplete tests. |
use p: and f: prefixes for properties/fields respectively
(we can remove these again if too annoying)
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp | ||
---|---|---|
96 |
Yes, this makes sense to me. I looked at your example screenshot and wasn't sure whether they were both fields or whether one of them was a property -- I think there's value in indicating explicitly what they are.
I do think there's a fair chance of conflicts -- many of the attribute names here are short and generic and look like likely field names (e.g. kind, type). Even if the chance of a conflict is relatively low, a conflict will be pretty confusing when it does happen -- and given that we'll be using this feature when we're debugging (i.e. already confused), I think this is worth avoiding. One more question: How do the "p:" and "f:" items sort in the output? I think these should be sorted together and grouped -- e.g. builtins first, then fields, then properties. (Yes, I know this is more work... but I think it's worth it.) | |
121–123 | Are you sure? I can see nothing here that would indicate this: https://en.cppreference.com/w/cpp/language/structured_binding And Clang doesn't complain in -std=c++17: |
display properties at the end of the kv list
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp | ||
---|---|---|
96 |
Javascript objects are ordered these days, so they'll display in the order we output them here. | |
121–123 | Hmm, what about this :-)
The capture is the problem: https://godbolt.org/z/e5P43G754 |
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp | ||
---|---|---|
96 |
Got it, thanks.
SG | |
121–123 | Ah, thanks -- that's the bit I didn't understand. |
IIUC, this places properties on the current HTML element as attributes, just like the built-in attributes that we add for other purposes (e.g. "value_id", "kind").
Suggestion: Can we nest all properties inside of a "properties" attribute?
Edit: Having looked at the HTML template now, I see that we exclude certain attributes there ('kind', 'value_id', 'type', 'location') when listing properties. I still think naming conflicts are a potential problem though. I think it would also be clearer to explicitly pick the properties out of a properties attribute rather than excluding a blocklist of attributes.