Questions tagged [llvm-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
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
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
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
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
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
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...
1

votes
0

answer
101

Views

can clang static analyzer create .plist files in custom directory?

By default Clang-static-analyzer creates .plist files in current directory (from where the static analyzer is run). Is there any way to make it generate .plist files in a custom directory?
Hemant
1

votes
0

answer
81

Views

Clang diagnostics and clang-check differs in warning count

For the following snippet #include enum index{ one = 5, two, three, four, five }; int fun(){ int arr[3] = {1,2,3}; int i = arr[index::one]; printf('%d\n', i); int j = arr[index::four]; printf('%d\n', j); return 0; } Clang diagnostic reports two warnings (which is actually correct) whereas clang-...
Hemant
1

votes
0

answer
242

Views

Using clang static analyzer with cross compiled toolchain

I am trying to set up static analysis for our code base which is cross compiled for a ARM based CPU. It appears that scan-build provided by clang is one of the best open source solutions for this. When I run scan-build, this is what I get. $ scan-build-3.8 --use-cc=arm-linux-gnueabi-gcc --analyzer-t...
Rohit Walavalkar
1

votes
0

answer
84

Views

Parse GCC builtin functions with Clang

I want to know if it is possible to parse GCC builtin functions with clang like int __builtin_ctz (unsigned int x), int __builtin_clz (unsigned int x). The reason I want to do so is that if I try and parse a C++ file including any of the standard libraries, and with correct include folders, the cla...
Moustafa Mahmoud
1

votes
1

answer
638

Views

Clang 3.8 error: invalid linker name in argument '-fuse-ld=gold-2.25'

I am using Clang 3.8 on CentOS 7.4 to compile a C++ app using third party libraries and their (complicated) makefiles. When including their makefile and running my own I am getting the following error during linkage: clang-3.8: error: invalid linker name in argument '-fuse-ld=gold-2.25' I had a look...
user997112
1

votes
0

answer
31

Views

How does LLVM emit AArch64's JumpTable?

There are ARM32's JumpTable description in ArmAsmPrinter.cpp, but there aren't any information of AArch64's JumpTable in AArch64AsmPrinter.cpp But, Compiler can emit JumpTable to Binaries. So, how does LLVM do it?
Twinkle HanA
1

votes
0

answer
99

Views

R calling user path to clang+llvm

how do we reset the paths that R uses to call clang: When trying to compile R package from source I get the the following error: * installing *source* package ‘sf’ ... ** package ‘sf’ successfully unpacked and MD5 sums checked configure: CC: /Users/user_name/opt/clang+llvm-4.0.1-x86_64-apple...
user2953274
1

votes
0

answer
136

Views

How to get the source text from line number using clang?

I am using clang matcher to obtain the result nodes. From the result nodes, I am able to get the line number, let us say 17. Now, I would like to get the entire source code in that line. Please help. Let me explain in detail. I have a clang matcher that finds the floating literal in the source code....
The Voyager
1

votes
1

answer
156

Views

How to extract headers from source file using clang?

I am using clang ast matcher to extract some information fromt the source file. Now, I would also like to know the list of headers and dependency headers that the source file is using. For example, the source file abc.c has following header: #include //#include During clang matcher, I need to make...
The Voyager
1

votes
0

answer
57

Views

Is there a way to disable a specific llvm lld warning?

I'm getting the following warning from llvm 6.0.0 lld while linking to the libiomp5.so which I'm getting pre-built from the llvm 6.0.0 ubuntu 14.04 download (here) warning: found local symbol '__kmp_gtid' in global part of symbol table in file {some_path}/libiomp5.so As far as I can tell this is an...
David
1

votes
0

answer
32

Views

Copy source code between two source locations in Clang

I am writing a Clang plugin that should extract some information out of my source file. I've obtained two source locations with the help of ASTContext and its getFullLoc function. How can I extract/copy the source code between these two source locations?
Gizmo
1

votes
1

answer
184

Views

clang tool : include path

I would like to change my clang tool's include path according to input. When I run the below code on a sample test file I have a compilation error 'header not found'. #include 'clang/Frontend/FrontendActions.h' #include 'clang/Tooling/CommonOptionsParser.h' #include 'clang/Tooling/Tooling.h' // Decl...
ogzu rasa
1

votes
0

answer
212

Views

How to provide header files when parsing C++ files using libtooling Clang API

I'm trying to build a source-to-source translation tool using Clang LibTooling based on this tutorial. Here is the code that I'm using to pass the C++ source code file to be parsed as arguments to my program: int main(int argc, const char **argv) { CommonOptionsParser OptionsParser(argc, argv, MyToo...
keheliya
1

votes
0

answer
129

Views

Compile a 32-bit libfuzzer application on the 64-bit linux

Recently, I've been familiar with libfuzzer and want to give it a go. Well, as far you know for using Sanitizer it's better to compile the binary in 32bit mode because it on 64bit system requests a lot of memory. So, when I'm trying to compile my fuzzer in 32bit mode (-m32) with clang-6.0, I get the...
alex se
1

votes
0

answer
140

Views

Pass not working anymore : undefined symbole _ZN4llvm24DisableABIBreakingChecksE

I had a very well working LLVM pass, but it seems to not work anymore for a very mysterious reason. I have also tried to make a basic tutorial pass work following this. But it gives me the same error: error: unable to load plugin '/Clang/llvm-pass-tutorial-master/build/skeleton/libSkeletonPass.so':...
guillau4
1

votes
1

answer
109

Views

Clang Windows LD Set Library Path Not Work?

Compiling on windows with 6.0.0 or 6.0.1 ld.lld can't find the library in specified path. This does not work: ld.lld Source.o -o Executable.exe -L'C:/Users/Username/Documents/' libcode.a But this does: ld.lld Source.o -o Executable.exe C:/Users/Username/Documents/libcode.a Am I doing something wrong...
SedatedSnail
1

votes
0

answer
59

Views

How to use AST for both custom front-end action and clang static analysis

I am working on a libTooling based project where I have written a custom frontend action class by referring this. Now I want to run clang static analysis in the same tool. Currently, I am running the tool again for clang static analysis (after modifying compiler options). But this will parse the fil...
Hemant
1

votes
0

answer
38

Views

Ignore inline assembly related diagnostic errors in clang-tidy

I am trying to use clang-tidy (version 6.0.0) to run some static analysis on a code base that is supposed to run on a custom control processor. It works quite well except for some diagnostic errors that it generates whenever it encounters inline assembly. For example: error: unknown register name '...
Vijay
1

votes
0

answer
55

Views

Why “-fno-inline” brings so bad performance in clang?

We use clang to compile IR code, then execute the IR in some place. For some reasons, we add '-fno-inline' in compile options, which brings very bad performance. Before the IR code takes less than 1ms, after open '-fno-inline', the IR code takes more than 20ms. From my understanding, inline only eli...
Tongxuan Liu
1

votes
1

answer
41

Views

How to detect all buffer access by using Clang Static Checker

My target: detect all buffer access in C/C++ by using clang static checker. My idea: use CheckPosition to get all memory read/write and then filter unrelated items. My problem: However, I got stuck when I try to filter something like 'int i = 1' 'i++'. My solution: One way to filter this is to c...
chaz
1

votes
0

answer
139

Views

LLVM Cross Compiling to MIPS on Windows x64

I am trying to compile a very simple Hello World C-program to MIPS assembly on a winx64 machine using llvm/clang. I have searched for this issue and whilst there are a number of threads with similar topics they almost exclusively use linux and more often than not do not provide any form of solution....
AlexS87
1

votes
0

answer
38

Views

Disable debug file generation with clang

I am using android ndk version 18b to compile a c++ project for Android on Windows 10. I am wondering if there is a way to disable generating the debug symbols when linking, in an effort to speed up link times. Since I do not have a graphical debugger, the frequency of when I fire up gdb command lin...
ScottF
1

votes
1

answer
50

Views

Detecting Integer Comparison conditional in LLVM

#include #include int main (){ unsigned short int a = 10; if (a == 10){ //something } } In an LLVM pass, how would I detect 2 operand integer comparison conditional statements like the one shown above: (a == 10)? Please let me know what I should look for in the LLVM api.
Nemo_Sol
1

votes
0

answer
191

Views

How to set up llvm-symbolizer?

I was able to push the ASAN related libs located in ANDROID_SDK using the script 'asan_device_setup' located inside 'Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/7.0.2/bin' from my MacOS. However, I am unable to get any symbol information for the Address Sanitizer call s...
user1128265
1

votes
0

answer
34

Views

llvm Costmodel Analysis Pass is showing different result via opt compared to my own project

I have a llvm IR file that includes instructions like fadd and fmul. These instructions when calculating the cost with the cost-model pass opt -analyze -targetlibinfo -cost-model myIRFile.ll I have also created my own pass and run this pass in my code. But when I do this I am getting different resu...
Mark
1

votes
1

answer
130

Views

Can clang-cl flags -fprofile-instr-generate -fcoverage-mapping be used in windows

I'm using clang 7 in windows and linux to generate coverage on c++ project. In linux I can successufuly generate all coverage information simply by adding compilation flags: -fprofile-instr-generate -fcoverage-mapping But in windows it returns me linker errors and also llvm-cov does not exist in ll...
Nuno
1

votes
0

answer
144

Views

Using MSVC with QT creator: The clangbackend process has finished unexpectedly and was restarted

I'm using Qt Creator 4.7.2 and when I try to make a project using Desktop QT 5.11.2 with MSVC2015 32 bit compiler I get a repeating message under general messages: Clang Code Model: Error: The clangbackend process has finished unexpectedly and was restarted. This message is repeating 3 times every s...
user9225608
1

votes
2

answer
70

Views

Building call graphs using Clang AST, link parameters to arguments

I am trying to build call graphs using Clang AST. Is there a way to somehow link the parameters of a function to the arguments of an inner function call? For example, given the following function: void chainedIncrement(int *ptr) { simplePointerIncr(ptr); for (int i=0;i
Marco
1

votes
0

answer
50

Views

Clang crash with multiple hierarchical classes and structs?

My project consists of multiple hierarchical structs and classes, the maximum hierarchy of some being around 900. Clang seems to not take this well and crashes. Upon re-compiling, it continues compilation but crashes again with a similar output. Thread 0 Crashed:: Dispatch queue: com.apple.main-thre...
SagunKho
1

votes
1

answer
39

Views

Create debug location for function calls in LLVM function pass

I have created an optimization (function) pass that instruments specific instructions and creates function calls before target instructions. It works fine, but I cannot enable debug symbols (-g) due to not having a debug location for my custom function calls. i8* %381 = call i8* @my_function(i64* %...
Amir Saman
1

votes
0

answer
30

Views

Cross-compiling to ARM

I am trying to cross-compile from x86 to ARM using LLVM. I have built a standard version of LLVM on x86 (which works). Now I am running the following command: clang++ -v -g3 -O0 $< -o [email protected] $(FLAGS) -rdynamic --target=${ARM_TRIP} \ --sysroot=${SYSROOT}/libc \ -I${SYSROOT}/include/c++/8.2.1 \ -I${SYSROO...
baum
1

votes
1

answer
47

Views

Running Clang-query on objective-c files that import Foundation

I am trying to use clang-query to run matches against obj-c files that import Foundation but its not working, After building clang-query by moving it to the tools/extra folder, I run it using this command: ./clang-query MyClass.m -- -extra-arg-before '-isysroot/Applications/Xcode.app/Contents/Deve...
Andrespch
1

votes
1

answer
39

Views

How make clang-tidy apply FixItHints sequentially, one after another?

I'm writing clang-tidy check that will move comment in right place like that: Before: /// comment 1 void func(); void func2(); /// comment 2 void func3(); /// comment 3 After: /// comment 1 void func(); /// comment 2 void func2(); /// comment 3 void func3(); I'm trying to remove /// comment 3 and th...

View additional questions