Last active
October 10, 2021 14:31
-
-
Save ppmathis/90c804d3f9e6b2474d4d7d346c0803d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-std=c++20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "main.hpp" | |
// all good | |
static constexpr Container ct1 = Container(); | |
// clangd complaints about three false positives: | |
// - [invalid_consteval_call] Line 4: call to consteval function 'Container<Value, Value>::Container' is not a constant expression | |
// - [constexpr_var_requires_const_init] Line 4: constexpr variable 'ct2' must be initialized by a constant expression | |
// - [invalid_consteval_call] Line 1: in included file: call to consteval function 'Value::raw' is not a constant expression | |
static constexpr Container ct2 = Container(Value(1), Value(2)); | |
int main() { | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstddef> | |
#include <cstdint> | |
#include <utility> | |
class Value final { | |
private: | |
uint64_t raw_; | |
public: | |
consteval explicit Value(uint64_t value) : raw_(value * 2){}; | |
[[nodiscard]] consteval uint64_t raw() const { | |
return raw_; | |
} | |
}; | |
template <class... Values> | |
class Container { | |
public: | |
consteval explicit Container(Values&&... values) : next_entry_(0), entries_() { | |
(Push(std::forward<Values>(values)), ...); | |
}; | |
private: | |
static constexpr size_t kEntryCount = sizeof...(Values); | |
size_t next_entry_; | |
uint64_t entries_[kEntryCount]; | |
consteval Container& Push(Value value) { | |
entries_[next_entry_++] = value.raw(); | |
return *this; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I[16:21:22.573] clangd version 13.0.0 (https://github.com/llvm/llvm-project d7b669b3a30345cfcdb2fde2af6f48aa4b94845d) | |
I[16:21:22.573] Features: linux+grpc | |
I[16:21:22.573] PID: 489995 | |
I[16:21:22.573] Working directory: /home/ppmathis/Development/cpp-playground | |
I[16:21:22.573] argv[0]: /home/ppmathis/Downloads/clangd/clangd_13.0.0/bin/clangd | |
I[16:21:22.573] argv[1]: --check=main.cpp | |
I[16:21:22.573] argv[2]: --log=verbose | |
V[16:21:22.573] User config file is /home/ppmathis/.config/clangd/config.yaml | |
I[16:21:22.573] Entering check mode (no LSP server) | |
I[16:21:22.573] Testing on source file /home/ppmathis/Development/cpp-playground/main.cpp | |
I[16:21:22.573] Loading compilation database... | |
I[16:21:22.574] Loaded compilation database from /home/ppmathis/Development/cpp-playground/compile_flags.txt | |
V[16:21:22.575] Broadcasting compilation database from /home/ppmathis/Development/cpp-playground | |
I[16:21:22.576] Compile command from CDB is: /home/ppmathis/Downloads/clangd/clangd_13.0.0/bin/clang-tool -std=c++20 -resource-dir=/home/ppmathis/Downloads/clangd/clangd_13.0.0/lib/clang/13.0.0 -- /home/ppmathis/Development/cpp-playground/main.cpp | |
I[16:21:22.576] Parsing command... | |
I[16:21:22.579] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/ppmathis/Development/cpp-playground -resource-dir /home/ppmathis/Downloads/clangd/clangd_13.0.0/lib/clang/13.0.0 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/backward -internal-isystem /home/ppmathis/Downloads/clangd/clangd_13.0.0/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/ppmathis/Development/cpp-playground -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /home/ppmathis/Development/cpp-playground/main.cpp | |
I[16:21:22.580] Building preamble... | |
I[16:21:22.659] Indexing headers... | |
V[16:21:22.670] indexed preamble AST for /home/ppmathis/Development/cpp-playground/main.cpp version null: | |
symbol slab: 2191 symbols, 582160 bytes | |
ref slab: 0 symbols, 0 refs, 128 bytes | |
relations slab: 234 relations, 4376 bytes | |
V[16:21:22.680] Build dynamic index for header symbols with estimated memory usage of 2092580 bytes | |
V[16:21:22.681] Built preamble of size 1010908 for file /home/ppmathis/Development/cpp-playground/main.cpp version null | |
I[16:21:22.681] Building AST... | |
E[16:21:22.686] [invalid_consteval_call] Line 4: call to consteval function 'Container<Value, Value>::Container' is not a constant expression | |
E[16:21:22.686] [constexpr_var_requires_const_init] Line 4: constexpr variable 'ct2' must be initialized by a constant expression | |
E[16:21:22.686] [invalid_consteval_call] Line 1: in included file: call to consteval function 'Value::raw' is not a constant expression | |
I[16:21:22.686] Indexing AST... | |
V[16:21:22.686] indexed file AST for /home/ppmathis/Development/cpp-playground/main.cpp version null: | |
symbol slab: 3 symbols, 4912 bytes | |
ref slab: 7 symbols, 13 refs, 4416 bytes | |
relations slab: 0 relations, 24 bytes | |
V[16:21:22.686] Build dynamic index for main-file symbols with estimated memory usage of 13000 bytes | |
I[16:21:22.686] Testing features at each token (may be slow in large files) | |
V[16:21:22.686] 0:0 # | |
V[16:21:22.686] definition: 1 | |
V[16:21:22.686] hover: false | |
V[16:21:22.686] 0:1 include | |
V[16:21:22.686] definition: 1 | |
V[16:21:22.686] hover: false | |
V[16:21:22.686] 0:9 "main.hpp" | |
V[16:21:22.686] definition: 1 | |
V[16:21:22.686] hover: false | |
V[16:21:22.686] 2:0 static | |
V[16:21:22.686] definition: 1 | |
V[16:21:22.686] hover: true | |
V[16:21:22.686] 2:7 constexpr | |
V[16:21:22.687] definition: 1 | |
V[16:21:22.687] hover: true | |
V[16:21:22.687] 2:17 Container | |
V[16:21:22.687] definition: 1 | |
V[16:21:22.687] hover: true | |
V[16:21:22.687] 2:27 ct1 | |
V[16:21:22.687] definition: 1 | |
V[16:21:22.687] hover: true | |
V[16:21:22.687] 2:31 = | |
V[16:21:22.687] definition: 1 | |
V[16:21:22.687] hover: true | |
V[16:21:22.687] 2:33 Container | |
V[16:21:22.687] definition: 1 | |
V[16:21:22.688] hover: true | |
V[16:21:22.688] 2:42 ( | |
V[16:21:22.688] definition: 1 | |
V[16:21:22.688] hover: true | |
V[16:21:22.688] 2:43 ) | |
V[16:21:22.688] definition: 1 | |
V[16:21:22.688] hover: true | |
V[16:21:22.688] 2:44 ; | |
V[16:21:22.688] definition: 1 | |
V[16:21:22.688] hover: true | |
V[16:21:22.688] 3:0 static | |
V[16:21:22.688] definition: 1 | |
V[16:21:22.689] hover: true | |
V[16:21:22.689] 3:7 constexpr | |
V[16:21:22.689] definition: 1 | |
V[16:21:22.689] hover: true | |
V[16:21:22.689] 3:17 Container | |
V[16:21:22.689] definition: 1 | |
V[16:21:22.689] hover: true | |
V[16:21:22.689] 3:27 ct2 | |
V[16:21:22.689] definition: 1 | |
V[16:21:22.689] hover: true | |
V[16:21:22.689] 3:31 = | |
V[16:21:22.689] definition: 1 | |
V[16:21:22.690] hover: true | |
V[16:21:22.690] 3:33 Container | |
V[16:21:22.690] definition: 1 | |
V[16:21:22.690] hover: true | |
V[16:21:22.690] 3:42 ( | |
V[16:21:22.690] definition: 1 | |
V[16:21:22.690] hover: true | |
V[16:21:22.690] 3:43 Value | |
V[16:21:22.690] definition: 1 | |
V[16:21:22.690] hover: true | |
V[16:21:22.691] 3:48 ( | |
V[16:21:22.691] definition: 1 | |
V[16:21:22.691] hover: true | |
V[16:21:22.691] 3:49 1 | |
V[16:21:22.691] definition: 1 | |
V[16:21:22.691] hover: false | |
V[16:21:22.691] 3:50 ) | |
V[16:21:22.691] definition: 1 | |
V[16:21:22.691] hover: true | |
V[16:21:22.691] 3:51 , | |
V[16:21:22.691] definition: 1 | |
V[16:21:22.691] hover: true | |
V[16:21:22.691] 3:53 Value | |
V[16:21:22.691] definition: 1 | |
V[16:21:22.692] hover: true | |
V[16:21:22.692] 3:58 ( | |
V[16:21:22.692] definition: 1 | |
V[16:21:22.692] hover: true | |
V[16:21:22.692] 3:59 2 | |
V[16:21:22.692] definition: 1 | |
V[16:21:22.692] hover: false | |
V[16:21:22.692] 3:60 ) | |
V[16:21:22.692] definition: 1 | |
V[16:21:22.692] hover: true | |
V[16:21:22.692] 3:61 ) | |
V[16:21:22.692] definition: 1 | |
V[16:21:22.692] hover: true | |
V[16:21:22.692] 3:62 ; | |
V[16:21:22.693] definition: 1 | |
V[16:21:22.693] hover: true | |
V[16:21:22.693] 5:0 int | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 5:4 main | |
V[16:21:22.693] definition: 1 | |
V[16:21:22.693] hover: true | |
V[16:21:22.693] 5:8 ( | |
V[16:21:22.693] definition: 1 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 5:9 ) | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 5:11 { | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 6:2 return | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 6:9 0 | |
V[16:21:22.693] tweak: ExtractVariable | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 6:10 ; | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
V[16:21:22.693] 7:0 } | |
V[16:21:22.693] definition: 0 | |
V[16:21:22.693] hover: false | |
I[16:21:22.693] All checks completed, 3 errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment