[all-commits] [llvm/llvm-project] fe7afc: [clangd] Remove inline Specifier for DefineOutline...

bgluzman via All-commits all-commits at lists.llvm.org
Fri May 26 01:49:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe7afcf70c93223a16ec7a2a5e07c4ace16c9a04
      https://github.com/llvm/llvm-project/commit/fe7afcf70c93223a16ec7a2a5e07c4ace16c9a04
  Author: Brian Gluzman <bgluzman at gmail.com>
  Date:   2023-05-26 (Fri, 26 May 2023)

  Changed paths:
    M clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
    M clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

  Log Message:
  -----------
  [clangd] Remove inline Specifier for DefineOutline Tweak

`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.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D151294




More information about the All-commits mailing list