Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Bulid results are available at http://results.llvm-merge-guard.org/Phabricator-36
See http://jenkins.llvm-merge-guard.org/job/Phabricator/36/ for more details.
Mostly LG, but please take a look at the NITs and the implementation-related comments.
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
415 | This should return SmallVector<ReferenceLoc, 2> now, some declarations can have both decl and non-decl references. | |
418 | We don't need this flag, in every case we now whether a reference points to a decl or not. | |
455 | Similar to DeclaratorDecl, let's handle this in VisitNamedDecl | |
460 | This should be handled in VisitNamedDecl, we should use a helper similar to getQualifier from AST.h to get the qualifier loc instead. | |
465 | NIT: don't use negative flags, they are hard to read. Prefer IsDeclRef | |
469 | Why do we need this in the first place? | |
497 | Same here: types don't declare anything normally, remove this field and use false directly instead. | |
675 | NIT: please add /*IsDecl=*/ comment here and in other places to make reading the code simpler. | |
762 | NIT: maybe use declaration instead? | |
clang-tools-extra/clangd/FindTarget.h | ||
90 | Initialize to make sure we can't ever have UB when using this struct. | |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
528 | Why do we need this? Can't we test everything we do by putting into foo? The original idea was to avoid too much output in the tests by letting the setup code live outside the function that's being annotated. I know it's a weird limitation, but that's one that was already made and I'd keep it this way if it's possible. | |
594 | We should keep these non-declaration references. |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
415 | Can you give some examples? It seems that non-decl references are handled by other refIn* functions. int Foo = OtherBar; // OtherBar is captured at the momment. | |
460 | good point, didn't aware of this utility method, exposed it in AST.h. | |
762 | changed to decl. | |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
528 | I tried it but failed. We can't test the qualified definitions (see example below) if we put everything into function foo (as defining a namespace is not allowed inside a function) namespace $0^ns { class $1^Foo { void $2^method(); }; void $3^func(); } void $4^ns::$5^Foo::$6^method() {} void $7^ns::$8^func() {} |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
415 | namespace $1[[a]] = $2[[std]]; $1 is a declaration of a namespace alias. |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
---|---|---|
528 | Fair point, but this patch does not add support for references in qualifiers of declarations. We can totally test all things added by this patch inside the function body. Could you split the part that adds tests for qualifiers into a separate change? |
clang-tools-extra/clangd/AST.cpp | ||
---|---|---|
114 | could you move this one back above getQualifierLoc ? | |
clang-tools-extra/clangd/FindTarget.cpp | ||
415 | I was just about to make the same point. After this patch lands I would like to detect using namespaces inside function body, and currently there is no way to distinguish between a usingdirective and a namespacealias. Since both is only referencing the target namespace. So even if this starts reporting $2 in the comment above, there should be a difference between that and $3 in using namespace $3[[std]]; |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
---|---|---|
849 | Could we avoid adding this test in this revision? | |
853 | Could we avoid reporting destructor references for now? I feel they would create more confusion than bring value. I believe they're not critical to any of the use-cases we have so far, having a `// FIXME: decide how to surface destructors when we need them should be good enough for now |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
437 | This one is a not a declaration reference. Note that this would require returning two results from this function. |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
415 | That's intentional, though. When we report references, we deliberately leave out information on where it's coming from - otherwise it's hard to encode it. However, if we really need that, we could also pass a NamedDecl* when reporting declarations (that would mean a slightly different interface, though). We still have some complexity budget in findExplicitReferences and we should probably spend it here. I'd suggest we keep this patch with IsDecl flag, but happy to look into your use-case with using namespaces more closely... |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
---|---|---|
853 | Agree. it is not needed in rename feature as well, we have a typeLoc occurrence in ~[[Foo]]. |
Mostly NITs from my side, the change LG, thanks!
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
422 | Same comment as below: could you say ReferenceLoc explicitly here and in other places? | |
438 | NIT: maybe put this comment on a previous line? | |
672 | I'd probably suggest to return SmallVector<ReferenceLoc, 2> from all functions, so that they compose better in this situation. Although Optional<ReferenceLoc> captures the semantics of some of those better, I don't think it's particularly useful at this point. | |
673 | NIT: add braces around an inner multi-line if? | |
675 | Could we have {ReferenceLoc{ instead of {{? | |
681 | Remove this comment? Seems to be a leftover from experiments | |
clang-tools-extra/clangd/unittests/XRefsTests.cpp | ||
2280–2281 | This looks unrelated. Maybe revert and land separately? |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
415 | as discussed offline, it is a special enough use-case to handle in define-inline. |
address remaining nits.
clang-tools-extra/clangd/unittests/XRefsTests.cpp | ||
---|---|---|
2280–2281 | This patch also modifies the getNonLocalDeclRefs which is related to the test here. I'd keep the change in this patch as it is minor and NFC. |
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
496 | Could we keep an llvm::Optional<> here in the visitor? The function can keep returning SmallVector, that's totally fine. | |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
603 | Similar to using namespace, this should be a non-decl reference. |
Build result: fail - 33449 tests passed, 2 failed and 463 were skipped.
failed: LLVM.tools/llvm-ar/mri-utf8.test failed: LLVM.tools/llvm-objdump/X86/disassemble-functions.test
Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt
could you move this one back above getQualifierLoc ?