Skip to content

Conversation

@kadircet
Copy link
Member

@kadircet kadircet commented Oct 5, 2023

No description provided.

@kadircet kadircet requested a review from sam-mccall October 5, 2023 16:06
@llvmbot llvmbot added clang Clang issues not falling into any other category clangd labels Oct 5, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 48a53509e851c93f352c967da1feb1c8fb2abd9a 80fa52f6efa36e04bf87c525013513d4429788ae -- clang/test/Index/USR/using-decl.cpp clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp clang/lib/Index/USRGeneration.cpp clang/test/Index/using_if_exists.cpp clang/test/Index/usrs.cpp
View the diff from clang-format here.
diff --git a/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp b/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp index 64c8834ab..c8e5c1cf9 100644 --- a/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp +++ b/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp @@ -202,8 +202,8 @@ TEST(SymbolInfoTests, All) { "def_bool"}, ExpectedSymbolDetails{"foo", "", "c:@F@foo#I#", "def_int", "def_int"}, - ExpectedSymbolDetails{"foo", "bar::", "c:TestTU.cpp@N@bar@UD@foo", - "decl"}}}, + ExpectedSymbolDetails{ + "foo", "bar::", "c:TestTU.cpp@N@bar@UD@foo", "decl"}}}, { R"cpp( // Multiple symbols returned - implicit conversion struct foo {}; 
Make sure we include filename and namespace for the target declarations.
Copy link
Collaborator

@sam-mccall sam-mccall left a comment

Choose a reason for hiding this comment

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

Thanks! This is a bit subtle, so I'm being a bit picky...

Can you add a more useful commit message?

VisitDeclContext(D->getDeclContext());
Out << "@UD";

// When the using-decl is resolved also print the context of the first target
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does "when the using-decl is resolved" mean?
I guess "when" just means "if", but UnresolvedUsing{Value,Typename}Decl aren't BaseUsingDecls, so what kind of "unresolved" are we talking about?

If it's just broken code, I think the comment isn't needed, the intent to defensively not-crash is clear.

VisitDeclContext(D->getDeclContext());
Out << "@UD";

// When the using-decl is resolved also print the context of the first target
Copy link
Collaborator

Choose a reason for hiding this comment

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

again, say why rather than what:

We may have both using ns1::foo and using ns2::foo bringing in different overloads. Consider them different symbols.


void USRGenerator::VisitBaseUsingDecl(const BaseUsingDecl *D) {
// Add the filename when needed to disambiguate using decls from different
// files.
Copy link
Collaborator

Choose a reason for hiding this comment

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

that much is clear from the code, it would be more useful to say why

our ideas about when using decls are the same vs different are dissimilar to other decls

void USRGenerator::VisitBaseUsingDecl(const BaseUsingDecl *D) {
// Add the filename when needed to disambiguate using decls from different
// files.
if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/false))
Copy link
Collaborator

Choose a reason for hiding this comment

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

as discussed offline, ShouldGenerateLocation doesn't seem like the right check here:

  • we definitely want to include the filename for *.cpp
  • we may want to include the filename for *.h
  • we probably should exclude system headers
  • for using decls inside functions, we need to include the filename if the function is not externally visible (though it's probably fine to include it always)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category clangd

3 participants