All Questions
Tagged with llvm-clang or clang
11,831 questions
-4 votes
0 answers
81 views
Clang 22 changes in returning temporary reference? [duplicate]
I know the following is undefined behaviour, but I'm wondering why my version of Clang won't compile it at all: class Registry2 {public: template <typename component_t> component_t& ...
-2 votes
2 answers
80 views
Change in module behavior for clang in GitHub
I've inherited a GitHub job I don't understand well and that has stopped compiling. It creates a .a library for iOS. The source consists of a set of modules, each declared thus: export module x; ...
3 votes
1 answer
119 views
std::filesystem::path::parent_path() GCC vs Clang behavior with multiple leading separators
I stumbled upon different behavior of std::filesystem::path::parent_path() when a path contains leading slashes. Clang says that the parent of ///a is /// (which is what I would expect), but GCC says ...
5 votes
2 answers
328 views
clangd in CUDA mode treats host-side C++ standard library as unavailable (std::format, chrono, iostream errors)
Problem I'm trying to use clangd for LSP in Neovim with CUDA .cu files, but it fails to recognize standard C++ library features on the host side. Even simple host functions using std::format, std::...
3 votes
2 answers
189 views
Why do GCC and Clang fail to auto-vectorize simple loop?
I have two functions counting the occurrences of a target char in the given input buffer. The functions vary only in how they communicate the result back to the caller; one returns the result and the ...
Tooling
0 votes
5 replies
96 views
A Clang tool to add extra line of code whenever a #define is true
I want to develop a tool that helps in transforming a code like this: #ifdef MYLIB_ENABLE_DEPRECATED_CODE ... some deprecated code ... #endif into: #ifdef MYLIB_ENABLE_DEPRECATED_CODE ...
0 votes
1 answer
45 views
mingw clang not generating .pdb file correctly
I'm compiling my program with -g -gcodeview to create the .pdb file info. It does. I'm also linking with: -g -Wl,--pdb= -lDbgHelp However, I get the following and the .pdb file is small - a few Kb. ...
2 votes
1 answer
114 views
C macro compilation fails in Clang with "expected ;" due to phantom comma in clang -E expansion
I wrote my "Result" macro header, using C23 and some of the newest features: #pragma once #include <stdio.h> #include <stdlib.h> #define __RESULT_EAT_PARENS(...) __VA_ARGS__ ...
0 votes
1 answer
35 views
Custom LLVM backend: error: unable to interface with target machine
Background I am writing a custom, globalISel only, backend for a currently unsupported processor. I have progressed to the point where I can run > clang -target xxx -emit-llvm file.c > llc -...
0 votes
0 answers
72 views
How to override the -fuse-ld flag in CLion?
I have a CMake based Windows library project that only links successfully with the MSVC link.exe due to some obscure third party library dependencies. However, I want to compile the project using the ...
2 votes
1 answer
140 views
Clangd query driver still uses clang source dir
Recently i've been working on some project with GNU arm compiler for C++ project. I've configured clangd to use this compiler with query-driver as clangd documentation recommends. The problem is ...
3 votes
0 answers
180 views
What is causing multi single-Byte access to packed Bit-field on GCC as opposed to single double word access on Clang?
While investigating some spurious tests in a x86-64Bit Yocto-based Linux system, that there were multi Byte writes to a register of a PCIe card, instead of an expected single double word write. A ...
2 votes
1 answer
182 views
Show compiler's estimate of branch/block probabilities
How can I get clang or compiler explorer to emit information about its internal calculated branch probabilities for a snippet of C++ code? It's OK if it's in IR at some optimization pass and not in ...
0 votes
2 answers
155 views
Any Clang diagnostic flag for preventing casting an invalid int value to an enum in C?
Clang's -Wassign-enum diagnostic flag will trigger a warning when using an int whose value is out of scope of an enum's cases: typedef enum Foo { FooA, FooB, } Foo; void handleFoo(Foo foo); ...
1 vote
1 answer
51 views
How can I correlate a clang::CXXMethodDecl with documentation comments that are in the header?
I am learning to work with the clang AST while developing a refactoring tool. I'm using a clang::ast_matchers::dynamic::DynTypedMatcher created using the clang::ast_matchers::dynamic::Parser::...