Questions tagged [clang++]

0

votes
0

answer
3

Views

Why implicit free's declaration is taken vararg parameter in llvm

Taken the following code int main() { int* a = (int*) malloc(sizeof(int) * 10); free(a); return 0; } If compile it to llvm IR by clang -S -emit-llvm -O0 -g, free's declaration is: declare i32 @free(...) #2 However, if I add #include , free's declaration is: declare void @free(i8*) #2 By adding inclu...
cgcgbcbc
1

votes
1

answer
27

Views

Clang-tidy incorrect rounding

Documentation for clang-tidy [bugprone-incorrect-roundings] check says: The number 0.499999975 (smallest representable float number below 0.5) rounds to 1.0 As far as I can detect the smallest float number below 0.5 is 0.4999999702, not a 0.499999975. But despite of this, both numbers give me 0 valu...
αλεχολυτ
1

votes
1

answer
45

Views

Xcode Apple Clang enable avx512

In Xcode(Version 10.1 (10B61)), I used Macro as below to detect AVX512 support. #ifdef __SSE4_1__ #error 'sse4_1' #endif #ifdef __AVX__ #error 'avx' #endif #ifdef __AVX2__ #error 'avx2' #endif #ifdef __AVX512__ #error 'avx512' #endif In default Build Settings, SSE4_1 is active, but avx, avx2 and is...
冯剑龙
0

votes
1

answer
7

Views

Ubuntu - how to set clang as default compiler using update-alternatives

I use Ubuntu 18.04 and I have two gcc/g++ versions which are managed using update-alternatives: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 --slave /usr/bin/g++ g++ /usr/bin/g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++...
Irbis
1

votes
0

answer
10

Views

Clang static code analyze does not create .plist results for modules that is build with Android.bp

Previously , I have implemented some modules under android/packages/services/ with using Android.mk and run clang static code analysis succesfully for this module , created .plist as the following: from android/ path I exported WITH_STATIC_ANALYZER=1 and I tried to run mmma packages/services/modul...
hasret ünal
1

votes
0

answer
64

Views

Clang exception capturing not working correctly

I'm using the clang x64 compiler on MacOS 10.12. I have the following code: try { throw CryptoPP::Exception(CryptoPP::Exception::OTHER_ERROR, 'test'); } catch(CryptoPP::Exception &e) { std::cout
Felix
1

votes
0

answer
343

Views

Cross-compile from x86-64 Ubuntu to Windows with clang++

The program is as follows: #include int main() { } Everything goes OK if I use clang++ helloworld.cpp But when I try to cross-compile it for Windows I get an error: clang++ helloworld.cpp -target x86_64-win32 helloworld.cpp:1:10: fatal error: 'iostream' file not found #include ^ 1 error generated....
user9162106
1

votes
1

answer
412

Views

Trying to cross compile Python I'm getting an unrecognised emulation mode

I've been working on a GitHub project that cross compiles Python for Android https://github.com/GRRedWings/python3-android/tree/clang Google is deprecating gcc in the NDK soon, so I have been trying to switch from using gcc, to clang. I stumbled across this project a couple of years back and have...
GR Envoy
1

votes
0

answer
657

Views

Created a symbolic link to /usr/bin/clang++-5.0, but the link only compiles C files

Ubuntu 16.04, no GCC. Installed clang: sudo apt install clang-5.0 Created two links: sudo ln -s /usr/bin/clang-5.0 clang sudo ln -s /usr/bin/clang++-5.0 cclang Compile a simple C file, helloworld.c. Either clang or cclang works fine. Try to compile a C++ file: cclang helloworld.cpp Got errors. Sa...
Bin
1

votes
1

answer
46

Views

Cast from uint8_t* to StringRef

I'm using ExecutionEngine.cpp. I want to get StringRef from found addresses by the following code: const APInt &IntVal; uint8_t *y2 = reinterpret_cast(const_cast(IntVal.getRawData())); int v2 = *reinterpret_cast(y2); StringRef* Src1V=cast(y2); I got this error: home/rasha/llvm/llvm/include/llvm/Sup...
R.Omar
1

votes
0

answer
54

Views

clang-format align postfix types in declarations

Is there any way to align postfix types using clang-format? I have the below options set but it seems to have no effect on declarations in typescript (postfix types) From the Clang 6 documentation: AlignConsecutiveAssignments (bool) If true, aligns consecutive assignments. This will align the assig...
Kyle Abramowitz
1

votes
1

answer
152

Views

C++ Xcode Undefined symbols for architecture [duplicate]

This question already has an answer here: What is an undefined reference/unresolved external symbol error and how do I fix it? 33 answers I get an error, when I try to compile my code with Xcode. You can see the error here: Undefined symbols for architecture x86_64: 'Sun::Datum2JDatum(Sun::Time)',...
Noxchi Graf
1

votes
0

answer
329

Views

R Studio package installation problems: clang version doesn't match?

I'm on a Mac OS Sierra WITHOUT admin privileges (ugh). There's a bunch of packages I really need to install, but for the vast majority, when I try to install, I get the following error: make: x86_64-apple-darwin13.4.0-clang: No such file or directory make: *** [base64.o] Error 1 ERROR: compilation f...
anon82
1

votes
0

answer
202

Views

invalid argument '-mmacosx-version-min=10.12' not allowed with '-mios-simulator-version-min=7.0'

I am building llvm-3.4 with clang in Mac OS 10.12, but after I successfully configure it with cmake-3.8.0(LLVM_ENABLE_PIC=FALSE,LLVM_TARGETS_TO_BUILD=ARM;Mips;X86,CMAKE_INSTALL_PREFIX=/my/install/path/) I build the program with Xcode 9.0, but I get this error message: clang: error:invalid argument...
Tim.He
1

votes
1

answer
55

Views

Does OpenMP hints bypass the vectorisation legality check in llvm

I am currently looking into how '#pragma omp for simd' is actually recognised in llvm. To my knowledge, clang will parse it and set metadata in IR to indicate this force-vectorisation hint and later optimisation passes would read it and vectorise the marked loop. Therefore, the loop should be vector...
PST
1

votes
0

answer
69

Views

clang error - library not found for DS.Store

I have an evasive problem trying to follow this example: http://docs.gluonhq.com/samples/gonative/: After correcting DekstopLogService to DesktopLogService I made sure I could call platform specific implementation correctly. I kept having problems with ios implementation which involves native Object...
lelelo
1

votes
0

answer
96

Views

Is it possible to make compiler split a returned structure value from a function into registers?

I'm looking for a way to have one (first) field of my structure returned from a function using a CPU register without allocating it on the stack. Assume we have a structure and functions returning it: template struct Pair { int code; T value; }; Pair FuncInt(bool const flag) { return {flag ? 0 :...
Dení
1

votes
0

answer
176

Views

Debugging Clang-generated RTTI code with GDB

I'm using Clang++ together with GDB. I've noticed that for some polymorphic classes GDB does not shows correct dynamic type. After some investigation it turned out that Clang puts different typenames in DWARF and RTTI : I have a template class: template< class T, sc_writer_policy POL> class sc_sign...
random
1

votes
1

answer
422

Views

How do I uninstall `libllvm3.8 (1:3.8-2ubuntu4)` and install `libllvm3.8 (= 1:3.8-2ubuntu1)`?

I'm trying to install UnrealEngine4 by following the instructions here: https://github.com/Microsoft/AirSim/blob/master/docs/build_linux.md. When I run ./Setup.sh in the UnrealEngine4 repository, I get the following error: The following packages have unmet dependencies: clang-3.8 : Depends: libclang...
Carson Tang
1

votes
1

answer
96

Views

Clang warning for pointers in if, for, while, etc

Is it possible to get a warning for this code, where a pointer is used in an if statement? NSObject *someObject = ...; if (someObject) { // warning here ... } I would like to require this instead, for clarity and safety: NSObject *someObject = ...; if (someObject != nil) { // warning here ... }
w8ite
1

votes
0

answer
920

Views

How to wrap a library(with c++11 feature) in CGO

My OS is Mac and the compiler is clang I want to wrap a C++ library (openfst , which uses C++11 feature ) in Go I follow the method of Scott Wales in How to use C++ in Go? , and the demo given by him works well( and no need to write makefile) First write a C wrapper for the C++ library. Use cgo to i...
chao.yang
1

votes
0

answer
60

Views

Exploring c++ forward declarations of nested types and a standards compliance teaser?

I recently, thanks to awesome Jan 9th 2018 planet clang team work and others great articles, figured out how to configure my dev-setup to integrate llvm 7.0, visual studio 2017 15.5.6 for 32-bit and 64-bit Intel architecture. My motivation for this was forced by Microsoft's 15.4.X breaking std lib...
smallscript
1

votes
0

answer
60

Views

Is Automatic Reference Counting now supported for i386?

As of Xcode 7.3, ARC seems to be working for 32-bit i386 projects. There's no longer a compile error and zeroing out weak references even works. It's even working when running on 10.10. However, I haven't been able to find any documentation stating that 32-bit ARC is officially supported and fully f...
Steve
1

votes
0

answer
226

Views

Building OpenCV with Clang 5 in Windows

I'm trying to build OpenCV in Windows 7 with Clang 5.0.0 but Cmake does not recognize the option and, therefore, there is no compilation available. The system contains Clang 5.0.0, MSVC 2013 Express and Cmake 3.10.0. Googling the solution does not show any valid results. There is any way to generate...
José Manuel Ramos
1

votes
1

answer
188

Views

Get rid of LLVM's Unconditional Branch

Consider this IR: label0: ret i32 0 br label %1 How do I get rid of the unconditional branch instruction? I have type casted it to BranchInst class and used removeFromParent() or eraseFromParent() but I'm getting this error. BranchInst *BI = dyn_cast(i); if(BI->isUnconditional()) BI->removeFromP...
Sourav Das
1

votes
0

answer
323

Views

Why am I getting these linker errors with cinder and CodeBlocks?

I'm having a bit of trouble compiling a project of mine using Code::Blocks and llvm-clang on Windows 10. Here's some of the error msg as its waay too long to fit in fully, but all of what should be needed is in there. clang++.exe -LC:\Qub3d\cinder_master\lib -o bin\Debug\Qub3d.exe obj\Debug\src\main...
TMcSquared
1

votes
0

answer
294

Views

Clang-format not adding brace to new line

I'm creating a rule to always add a new line before adding brace for functions, enums stucts etc. But it's having the opposite effect of changing all my code to keeping the brace on the same line. Expected Behavior: typedef enum { DATA = (1
homeGrown
1

votes
1

answer
182

Views

User defined integer literal not found

I am trying to create a user defined literal but get an error message when using it. GCC says unable to find numeric literal operator ‘operator''_uint’ while clang tells me error: no matching literal operator for call to 'operator''_uint' with argument of type 'unsigned long long' or 'const char...
Nobody
1

votes
0

answer
140

Views

How to build recent Clang RPMs for Red Hat 7?

I need to provide recent versions of Clang (5, 6 or 7 for test) to developers teams working on RH7.x boxes (today they are using the EPEL release 3.4.2) I would like to build same packages as the EPEL ones: (And the ability to change the RPM release if I need to rebuild them) clang-devel-6.0.0-1.el...
Destroyica
1

votes
0

answer
57

Views

Find clang::Type in Clang AST by name

In Clang AST, is it possible to find type by name? For example I have qualified name : nspace::my_type. How can I check if type is present in current translation unit?
random
1

votes
0

answer
82

Views

How to receive the current depth in RecursiveASTVisitor (clang)?

I try to understand several weeks the principles of operation with clang AST, but meanwhile I did not answer the main issue: how to walk on this tree? I read all guides which I found, studied doxygen documentation and even watched couple of lectures on YouTube, however the understanding did not come...
Mohenti Moro
1

votes
0

answer
80

Views

Clang link debug_info in executable on OSX

On OSX when you link a binary from multiple object files like this clang++ -g myfile.cpp -o myfile.o clang++ myfile.o -shared -o myfile.dylib it will generate a .debug_info section (etc.) in myfile.o but in myfile.dylib it just stores a reference to myfile.o and you have to run dsymutil myfile.dylib...
Timmmm
1

votes
0

answer
184

Views

clang static analyzer: Path diagnostic report is not generated

This is a Minimal, Complete, and Verifiable example: #include #include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QObject boo; QTimer::singleShot(0, &boo, []() { qDebug()
user1244932
1

votes
1

answer
107

Views

C++ Give compiler error for setting a (static) const global variable to another static const variable

Is it possible for clang to give a compiler error if you accidentally set a const global variable to another static const variable in C++ (in different translation units). Since the behaviour is pretty much undefined, it would be very useful to detect if doing this accidentally. EDIT: My question is...
keyboard
1

votes
0

answer
22

Views

xcode/clang - “clang diagnostics ignored” get reported

For cleanness of my code I have several compiler warnings, one of them is -Wextra-semi to report accidental ;;'s at the end of a line. However, some Google Maps macros do have an ; at the end so they end up with ;; at the end. To overcome this I thought 'Let's just ignore it, it's third party softwa...
MavEtJu
1

votes
0

answer
39

Views

Is it possible to make compiler emit diagnostics on default-initialized member?

Consider simple C++ code: class X { int a_, b_; public: X(int a) : a_(a) {} // b not mentioned in intializer list int get_sum() { return a_ + b_; } }; int foo () { X x(2); // x.b_ is indetermined return x.get_sum(); // returns garbage } In this snippet, x.b_ is default-initialized to indeterminate v...
1

votes
0

answer
37

Views

Using ClangTool to parse a string

The following code successfully sets up a ClangTool for parsing: std::vector source_files; cl::OptionCategory option_category('options'); CommonOptionsParser options_parser(argc, argv, option_category); ClangTool tool(options_parser.getCompilations(), source_files); However, I created argc and argv...
William Leiserson
1

votes
0

answer
53

Views

Optimizations in case of multiple virtual target invocations (i.e. 1, 2, 3)

I have below code which actually uses 1, 2, 3 virtual call targets: #include #include #include struct IMath { virtual ~IMath() = default; virtual int compute(int) = 0; }; struct MathAlg1: IMath { int compute(int i) final { return i * 17; } }; struct MathAlg2: IMath { int compute(int i) final { re...
Ionut B
1

votes
0

answer
65

Views

Are there aggregate initialization differences between std::vector and std::array?

In std::array, we can simply state like this std::array arr_gcc{ 'abcdefghi', 'abcdefghi' }; Or even in clang with -Wall, they just need somewhat more explicit expression, having to add some more subobject braces like this std::array arr_clang_wall_favor{{ {'abcdefghi'}, {'abcdefghi'} }}; When it c...
sandthorn
1

votes
0

answer
63

Views

Easiest way to evaluate constant SVal

I'm trying to find the easiest way to get the value in a constant SVal. Currently I am doing something along the lines of: SVal s = ...; // Get valid SVal from somewhere int64_t val = 0; // Will hold value of SVal if (!s.isUnknownOrUndef() && s.isConstant()) { switch (s.getBaseKind()) { case NonLocK...

View additional questions