Skip to content

C++: Remove getLocation from Container.#14337

Merged
jketema merged 4 commits into
github:mainfrom
aschackmull:cpp/container-not-locatable
Oct 25, 2023
Merged

C++: Remove getLocation from Container.#14337
jketema merged 4 commits into
github:mainfrom
aschackmull:cpp/container-not-locatable

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

Follow up to #14321

With the above-mentioned PR, Container now has conflicting urls provided by getURL and getLocation, respectively. This PR removes getLocation, since getURL ought to be sufficient. I was a bit in doubt about whether to switch the extends to Element or ElementBase, but it seemed that the additional predicates inherited from Element made little sense for Containers, so I chose ElementBase.

cc @jketema

@aschackmull aschackmull requested a review from a team as a code owner September 28, 2023 13:13
@github-actions github-actions Bot added the C++ label Sep 28, 2023
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Sep 28, 2023

Is it actually safe to just remove these, or do we need to go through a deprecation period?

@aschackmull
Copy link
Copy Markdown
Contributor Author

Is it actually safe to just remove these, or do we need to go through a deprecation period?

Good question. I just wanted to put up the diff for suggestion. The PR actually removes a whole bunch of other predicates as well that were previously inherited from Element - changing the type hierarchy like this is always tricky in terms of potential breakage. Maybe all of the removed predicates should be re-added as deprecated, but no longer inherited nor overriding.

@aschackmull
Copy link
Copy Markdown
Contributor Author

It's certainly breaking some tests. Do you perhaps want to take it from here? I don't feel strongly enough about this change to spend a lot of time on it.

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Sep 28, 2023

It's certainly breaking some tests. Do you perhaps want to take it from here? I don't feel strongly enough about this change to spend a lot of time on it.

I'll have a closer look.

@aschackmull
Copy link
Copy Markdown
Contributor Author

It's also perfectly fine to re-add

Location getLocation() {
    result.getContainer() = this and
    result.hasLocationInfo(_, 0, 0, 0, 0)
  }

on File without extending Locatable. A class doesn't need to extend Locatable to be able to provide a getLocation predicate.

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Sep 28, 2023

It's certainly breaking some tests.

I think it's breaking almost all the tests.

@jketema jketema force-pushed the cpp/container-not-locatable branch from ebdb6a8 to 550063d Compare September 29, 2023 11:42
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Sep 29, 2023

I've been looking at this a bit. I think File will still need to extend Element. Not having this just breaks too much code (code I'm not really willing to touch) and that code will need special cases for Files if I do touch it. There might still be consequences of Folder not having a getLocation, but those somewhat hidden for me due to all test regressions related to File not extending Element.

@aschackmull
Copy link
Copy Markdown
Contributor Author

I think File will still need to extend Element.

Sounds fine. In that case it might as well extend Locatable, since that doesn't add any member predicates, but merely indicates that getLocation can be expected to give something reasonable (which it does).

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Sep 29, 2023

I think File will still need to extend Element.

Sounds fine. In that case it might as well extend Locatable, since that doesn't add any member predicates, but merely indicates that getLocation can be expected to give something reasonable (which it does).

This fixes all the tests (see the internal PR that now links to this one).

Given the nature of this change, I'm tempted to make this one breaking instead of having a deprecation period. However, I'll need to check with some people that this reasonable.

@jketema jketema force-pushed the cpp/container-not-locatable branch from b93f629 to f7e6200 Compare October 24, 2023 09:47
@jketema jketema force-pushed the cpp/container-not-locatable branch from f7e6200 to 720a14a Compare October 24, 2023 09:49
@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Oct 24, 2023
@jketema jketema force-pushed the cpp/container-not-locatable branch 2 times, most recently from ab6ec51 to 89d932f Compare October 25, 2023 09:13
@jketema jketema requested a review from MathiasVP October 25, 2023 09:18
Copy link
Copy Markdown
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM! We should maybe run DCA on this to ensure that we didn't perturb any join orders, though?

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Oct 25, 2023

The changes LGTM! We should maybe run DCA on this to ensure that we didn't perturb any join orders, though?

Ran on the internal PR.

@jketema jketema force-pushed the cpp/container-not-locatable branch from 89d932f to 75a1173 Compare October 25, 2023 12:05
Copy link
Copy Markdown
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once DCA comes back happy 🤞

@jketema jketema merged commit 990d716 into github:main Oct 25, 2023
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Oct 25, 2023

DCA seems somewhat wobbly, but analysis times are unaffected.

@aschackmull
Copy link
Copy Markdown
Contributor Author

🎉 Thanks for taking over and getting this merged.

@aschackmull aschackmull deleted the cpp/container-not-locatable branch October 25, 2023 13:44
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Oct 25, 2023

🎉 Thanks for taking over and getting this merged.

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants