[PATCH] D151294: [clangd] Remove inline Specifier for DefineOutline Tweak
Brian Gluzman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 22:50:37 PDT 2023
bgluzman created this revision.
bgluzman added reviewers: kadircet, sammccall.
Herald added a subscriber: arphaman.
Herald added a project: All.
bgluzman requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
`inline` specifiers should be removed from from the function declaration and
the newly-created implementation.
For example, take the following (working) code:
cpp
// foo.hpp
struct A {
inline void foo() { std::cout << "hello world\n" << std::flush; }
};
// foo.cpp
#include "foo.hpp"
// main.cpp
#include "foo.hpp"
int main() {
A a;
a.foo();
return 0;
}
// compile: clang++ -std=c++20 main.cpp foo.cpp -o main
After applying the tweak:
// foo.hpp
struct A {
inline void foo();
};
// foo.cpp
#include "foo.hpp"
inline void A::foo() { std::cout << "hello world\n" << std::flush; }
// main.cpp
#include "foo.hpp"
int main() {
A a;
a.foo();
return 0;
}
// compile: clang++ -std=c++20 main.cpp foo.cpp -o main
We get a link error, as expected:
/usr/bin/ld: /tmp/main-4c5d99.o: in function `main':
main.cpp:(.text+0x14): undefined reference to `A::foo()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This revision removes these specifiers from both the header and the source file. This was identified in Github issue llvm/llvm-project#61295.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151294
Files:
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151294.525015.patch
Type: text/x-patch
Size: 6064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230524/55f0497e/attachment.bin>
More information about the cfe-commits
mailing list