Questions tagged [clang]

For questions about the clang LLVM compiler front end. For general questions about C, use the C tag.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

“.clang-tidy” file is ignorged (configuration file)

I have a long list of checks. To make the calling line shorter I would like to use the .clang-tidy file to create the config. According to the documentation, this config should be in the ...
0
votes
0answers
14 views

How to create custom checker for clang static analyzer?

I am trying to make new checker with clang static analyzer. I built the clang from source code using ninja and cmake. I am trying the instruction that was given in https://clang-analyzer.llvm.org/...
1
vote
1answer
79 views

Is there one more bug of the gcc compiler relative to inherited constructors?

This code does not compile using gcc HEAD 10.0.0 20190 but compiles using clang HEAD 9.0.0 #include <iostream> struct A { A() = default; A( int ) {} }; struct B { B() = default; ...
8
votes
0answers
103 views

Should a definition inside template class be instantiated if it is not used?

template <typename T> struct A { static constexpr T obj {}; static constexpr bool noexcept_copy = noexcept( T{obj} ); static void UsesCopy() { T{obj}; } static constexpr int C ...
0
votes
0answers
54 views

Why does libc++ not support such a basic atomic operation?

#include <atomic> int main() { std::atomic_size_t a{ 3 }; std::atomic_fetch_sub(&a, 1); // vc++ ok, but clang++ failed. } The code above is ok by vc++, but failed by clang++ 8.0 ...
1
vote
1answer
78 views

Why does Clang not like boost::transform_iterator?

With Clang 8.0.1 and Boost 1.70, the following program // transform.cpp #include <vector> #include <algorithm> #include <iostream> #include <boost/iterator/transform_iterator....
0
votes
1answer
18 views

Missing expected default Frameworks paths for clang on MacOS (/Library/Frameworks, etc.)

I am trying to build some fairly simple c++ code that relies on SDL2. Although I have xcode installed, I am invoking clang from the command line and not using xcode. The SDL2 framework is located ...
0
votes
0answers
12 views

Warning building Qt application for macos

I am building Qt application for MacOS. I am using Qt 5.9.7 While building I am seeing this warning: ld: warning: directory not found for option '-F/Users/user/Qt5.9.7/5.9.7/clang_64/lib' Where does ...
1
vote
1answer
24 views

How to ignore a custom warning in clang?

I can ignore predefined Clang warnings as follows: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" [target performSelector:selector]; #pragma ...
0
votes
1answer
36 views

cannot initialize a variable of type 'std::terminate_handler' (aka 'void (*)()') from libsupc++ library

I'm trying to compile libsupc++ with a clang. I got this error in file libsupc++/eh_term_handler.cc:45:36 I've tried to typecast the before initializing. But I'm not understanding 'void (*)()' data ...
0
votes
0answers
29 views

creating debug symbols throws warning line table paramters mismatch. Cannot emit

I'm trying to link a static library which needs xml2, libz, CFNetwork, UIKit, and MobileCoreServices with my tweak. My Makefile looks like ARCHS = arm64 TARGET = iphone::latest include $(THEOS)/...
0
votes
0answers
9 views

why functionDecl ast node can match struct of input file?

I want to find all function declaration and do some translation operations.I use clang-query to check functionDecl(), but match the struct. This is my ast matcher statement. clang-query> m ...
-4
votes
0answers
63 views

What is the function getExpansionLoc ,Clang [closed]

I need to know what does clang::SourceManager::getExpansionLoc give? I'm using RecursiveASTVisitor to traverse AST and when the if statement was visited ,calculatesgetExpansionLoc and ...
-2
votes
0answers
44 views

What is result when casting IfStmt::getThen()? [closed]

According to the below sample code, normally clang::IfStmt::getThen() result should be this two statements b = 2; c += a; I want to know whats happening when casting getThen() void foo(int a, int b, ...
0
votes
0answers
13 views

Reduce opencv4 dynamic lib .so size

I'm trying to reduce .so file size for an android app, but when I recompile the dynamic library my app crashes with this code java.lang.UnsatisfiedLinkError: No implementation found for long org....
1
vote
0answers
78 views

How to place a section of an input library into a special section of output ELF file while using lld?

I'm using clang for some bare-metal developing. It worked pretty good, until when I want to put the '.text' section from a static library, called 'libfw.a' here, into a special section, called '....
1
vote
0answers
14 views

where is clang executables after building LLVM?

Environment: Ubuntu 18.04 bionic. after git clone llvm-project from https://github.com/llvm/llvm-project. I generated build credentials using Cmake commandline like this: cmake -...
5
votes
1answer
64 views

ADL does not work in constexpr functions (clang only)

The following code compiles with MSVC and gcc, but not with clang. Why is that so? It seems like if ADL would not work if CallFoo () is constexpr. See the comment. template <class T> constexpr ...
1
vote
1answer
52 views

cannot execute the executable when linked with linker scripts

I am new to concept of linker scripts . So I was trying myself with simple c program and linker scripts and memory file. I tried to pass a custom linker script for a c program , When I looked into ...
1
vote
0answers
40 views

How to Clear Clang Precompiled Header Cache?

It seems Clang cached some stale headers, due to a time-drift error. How does one list what headers are precompiled and clears them?
-1
votes
0answers
53 views

How works 'TraverseDecl' function in the sample?

I'm new in clang and checking a project code but don't understand some parts of it, the below Code. i want to know how it works and what happens to EnumMap? and where VisitEnumDecl was called?!! The ...
2
votes
2answers
88 views

Why does libc++ not support class template argument deduction on multiset?

#include <set> int main() { auto coll = std::multiset{ 1, 2, 2, 3, 4, 4, 7 }; } The code above can be compiled by vc++ 2019 and g++ 9.0, but cannot be compiled by clang++ 8.0 as clang++ -...
0
votes
0answers
16 views

Is there any way I can find all macro expansion location?

I want to find all macro expansion location to replace the definition of macro. I don't know what API I can use to get the macro expansion location. include define NUM 5 int main(void) { int i;...
0
votes
1answer
41 views

How to set up googletest wtih meson?

I have a git repository with some test code in C++ and I want to use Googletest to write some tests. I used git submodule to get it as part of the above repository. I want to use meson as the build ...
0
votes
0answers
34 views

Error while compiling android kernel 4.4.189

I was trying to compile kernel for redmi note 7 (lavender) using these command: make O=out ARCH=arm64 lavender-perf_defconfig PATH="/media/quan/Data/linux-x86/clang-4691093/bin:/media/quan/Data/...
0
votes
0answers
16 views

How can I get the comment list from AST? Can I use AST->Comments.getComments()?

I am writing plug in to Clang AST. I want to collect all comments from clang AST. I see there is a Comments member under AST object and I used the Comments class member function getComments() but it ...
0
votes
0answers
24 views

How to refer AVR target shared library with llvmlite on x86-64

I have a header file and tried to write LLVM IR that calls a function which is included in the header file. this IR will be compiled eventually to the AVR target. According to this answer, I've run ...
2
votes
0answers
73 views

C++ type deduction of overloaded function [duplicate]

Is this legal code? #include <utility> #include <iostream> int main() { const auto func2 = std::swap<int>; } This code seems legal to me. But the compilers don't agree with ...
1
vote
1answer
67 views

How to print fully qualified Expr in clang?

I'm working on my reflection tool with clang 8.0.1. And right now I need to print Expr with all names fully qualified. I already tried builtin prettyPrint function with FullyQualifiedName bit set to ...
0
votes
0answers
19 views

How to get the object file when working on libtooling?

I have carried out some work on libtooling. I have created one tool called loop-covert which acts like a syntax-checker. I have one file compile_commands.json file. I have built the clang from ...
1
vote
0answers
104 views

Use python bindings to clang to check if a C++ type is a pointer, reference, etc. in canonical fashion?

Consider an object t of type clang.cindex.Type representing a C++ variable declaration such as const T& x; or a parameter declaration occurring in something like template<typename... Ts> ...
0
votes
1answer
25 views

Which assembler does clang use?

I am not clear on the assembler used by clang. AFAIK native aka GNU assembler and linker is used (provided along with gcc). clang -v main.c clang version 3.4.2 Target: x86_64-unknown-linux-gnu Thread ...
1
vote
0answers
20 views

Using gcc/clang builtins on windows

I'm trying to compile a c++ project on Windows. This project works perfectly on OSX/Linux. It uses a fair number of gcc builtins. popcount, builtin_expect etc. I know that MS-Visual-Studio has a ...
0
votes
0answers
37 views

False alarm in CLANG 3.42

CLANG gives a false alarm for vector null reference I am running CLANG version 3.4.2 with the following command: clang -std=c++11 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -I/home/...
0
votes
1answer
49 views

How to solve libatomic issue in windows?

I am developing executables from source code of llvm. So I downloaded the llvm source code from github. I am trying everything from command line on Windows OS I am following the link for libtooling ...
1
vote
1answer
28 views

Clang compiler auto-changed strcpy to memmov. macOS

When I compile with Clang on macOS (with or without xCode), the call into strcpy is auto-substituted to memmov. Is there a Clang flag to turn this off? int main(void) { char nice_message[6]; ...
3
votes
1answer
35 views

Why is private move constructor allowed while initalizing via static method?

Simplified code snippet is: class A { public: ~A(); static A create(); private: A() = default; A(A&&) = default; NonCopyable n; }; A A::create() { A a; return a; ...
0
votes
0answers
12 views

Unable to resolve : libatomic error occurred during configuring in cmake GUI

Hi I am trying to build clang-llvm from source code i have executed ninja command using the following link http://clang.llvm.org/docs/LibASTMatchersTutorial.html, I am facing exception during ...
2
votes
1answer
36 views

Writing AST matcher to find all case statements having no break statement

I want to find all the case statement having no break statement. I using clang-query to build my matcher. My matcher is failing in some of the test cases. I wrote simple matcher as match caseStmt(...
0
votes
0answers
20 views

Flutter try start app in iPhone simulator (error: cannot specify -o when generating multiple output files)

I create a new flutter app (new and blank, just created, in android studio with flutter plugin), and try build in iOS simulator. When I run in android, all works correctly... Error message: ...
0
votes
0answers
21 views

Clangd cannot find standard libraries in CLion

In CLion, Clangd underlines in red any includes from the standary C library like #include "stdint.h" and show a hint: 'stdint.h' not found. However it compiles and run fine. My guess is that Clangd ...
0
votes
0answers
13 views

Clang tool SIGBUS on multiple files using a clang::rewriter

I want to run some source to source transformation using clang. Instead of using the commonoptions for input Im using a JSONCompilationDatabase. It runs fine for a single file but it receives a ...
1
vote
1answer
57 views

LLD and the Linker Scripts

I am trying to send the linker scripts for one of the simple c program . I tried on both on Ubuntu and Windows. On Ubuntu After some research I found out that it was taking GNU-ld ,so With ...
1
vote
2answers
99 views

What can LLVM represent that C cannot? [closed]

As far as I know, it is almost true that any code that can be represented in the LLVM intermediate language, can also be represented in C, with two important exceptions: Exceptions. (No pun intended.)...
1
vote
1answer
47 views

(Objective-C++) Testing float value causes infinite loop

I'm trying my hand at coding an Objective-C(++) app from scratch and completely stumped as to why testing a float within a while loop appears to cause an infinite loop. Firstly, the file: test.mm #...
1
vote
1answer
28 views

clang 7 does not have std::map::merge?

When I use std::map's merge(source) I got an error: error: no member named 'merge' However, the std::map::merge should be there since c++17. I do add set(CMAKE_CXX_STANDARD 17) and -stdlib=libc++. ...
-1
votes
0answers
15 views

Passing static variable inside vector.assign produces - clang: error: linker command failed [duplicate]

I'm declaring a struct with the member variables: a vector v and a static const variable DEFAULT. In the constructor, the caller would pass the size of the vector n, and the constructor would then ...
0
votes
0answers
17 views

Specifying compiler versions in travis for cmake builds

The travis Building a C++ Project documentation shows how to specify gcc and clang compiler versions in build matrices. However, it does not show how to build projects with those compilers using cmake....
1
vote
0answers
56 views

How do I upload an object file generated by LLVM to Arduino?

I'm making a simple language for Arduino, and want to compile this with LLVM. I tried to generate LLVM IR (to understand what LLVM IR is generated from the Arduino code). I used this command: > ...
0
votes
1answer
41 views

How do I use C99 complex numbers with clang on Windows?

I have installed Visual Studio 2019 and it comes wih clang. I can successfully compile and link applications with clang. When I #include <complex.h> however, I do not get standard compliant ...