clang

Tensorflow的StreamExecutor编程

瘦欲@ 提交于 2020-04-06 13:56:07
首先了解一下结构化编译器前端Clang。 背景与概览 Low Level Virtual Machine (LLVM) 是一个开源的编译器架构,它已经被成功应用到多个应用领域。Clang ( 发音为 /klæŋ/) 是 LLVM 的一个编译器前端,它目前支持 C, C++, Objective-C 以及 Objective-C++ 等编程语言。Clang 对源程序进行词法分析和语义分析,并将分析结果转换为 Abstract Syntax Tree ( 抽象语法树 ) ,最后使用 LLVM 作为后端代码的生成器。 Clang 的开发目标是提供一个可以替代 GCC 的前端编译器。与 GCC 相比,Clang 是一个重新设计的编译器前端,具有一系列优点,例如模块化,代码简单易懂,占用内存小以及容易扩展和重用等。由于 Clang 在设计上的优异性,使得 Clang 非常适合用于设计源代码级别的分析和转化工具。Clang 也已经被应用到一些重要的开发领域,如 Static Analysis 是一个基于 Clang 的静态代码分析工具。 本文将简单介绍 Clang 的背景知识和功能特性,并通过一个小例子介绍如何使用 Clang 的库来编写一个小程序来统计源代码中的函数。 Clang 的开发背景 由于 GNU 编译器套装 (GCC) 系统庞大,而且 Apple 大量使用的 Objective-C

scan-build make does not detect any bugs

China☆狼群 提交于 2020-04-06 02:27:45
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

scan-build make does not detect any bugs

会有一股神秘感。 提交于 2020-04-06 02:25:51
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

scan-build make does not detect any bugs

谁说胖子不能爱 提交于 2020-04-06 02:25:04
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

百度App iOS工程化实践: EasyBox破冰之旅

半世苍凉 提交于 2020-04-05 22:32:58
本文作者:yanxin1563 本文作者: Yunpeng-基础技术 前言 百度App从单一的搜索工具发展到今天以搜索和Feed流为双引擎的综合性内容消费服务平台,其复杂程度已然不可同日而语矣。 作为一个日活过亿的超级App,业务规模庞大,相关技术人员超过千人,客户端支持主流的移动技术,涉及近百业务方,技术形态复杂,各种组件近三百个,代码百万量级,由此带来的工程化问题是技术团队的一个极大挑战。 项目的膨胀导致了很多不起眼的小问题被无限放大,组件管理不规范、编译时间长、工程文件合并冲突、Xcode默认非彻底编译隔离等等问题,导致开发人员在开发环境上耗费了大量时间。目前业界较流行的工具对于大规模工程的支持力度相对较弱,实践起来总是有些掣肘,难以达到理想状态。 EasyBox的诞生,就是致力于为超级App量身打造一套现代、高效、优雅的研发工具链。 这篇文章的主要目的是 站在工具链的角度 上,分享一下我们在实践工程化过程中一些经验。 概述 EasyBox主体由工程组装器(Installer)、多仓库管理工具(MGit)、二进制管理工具(LFS)三部分构成,分别负责工作区的构建(组件依赖分析、工程的生成与组合)、源码仓库的管理以及二进制的管理。EasyBox架构图: 由多仓库管理工具克隆所需仓库源码,由二进制管理工具下载二进制包,然后组装器根据描述表生成对应工程

How-to use Clang Static Analyzer on Windows?

你离开我真会死。 提交于 2020-04-05 06:45:15
问题 I'm currently trying to integrate the Clang Static Analyzer v9.0.1 into my CMake v3.16.5 build system using the Microsoft Visual C++ Compiler (MSVC) v19.25.28610.4 on a Windows v10.0.18363.720 operating system. Everything is build for the architecture x86_64. LLVM and Clang have been build from source. After some reading on the World Wide Web (WWW), there seems to be multiple ways to use the Clang Static Analyzer. Sadly the documentation is horrible and there seems to be some special quirks

How-to use Clang Static Analyzer on Windows?

眉间皱痕 提交于 2020-04-05 06:44:50
问题 I'm currently trying to integrate the Clang Static Analyzer v9.0.1 into my CMake v3.16.5 build system using the Microsoft Visual C++ Compiler (MSVC) v19.25.28610.4 on a Windows v10.0.18363.720 operating system. Everything is build for the architecture x86_64. LLVM and Clang have been build from source. After some reading on the World Wide Web (WWW), there seems to be multiple ways to use the Clang Static Analyzer. Sadly the documentation is horrible and there seems to be some special quirks

clang-format automatically changes function block comments, how to disable it?

耗尽温柔 提交于 2020-03-23 08:06:52
问题 When I select ColumnLimit any non-zero value. It converts block comments into Doxygen block comments (it adds space before * on a new line). But I do not want to change it. How can I disable it? My .clang-format file ColumnLimit: 100 IndentWidth: 4 TabWidth: 4 UseTab: Never It converts the following block comments /***************************************************************************** * A brief comments. * * @param theory . * ************************************************************

Multiple inconsistent behavior of signed bit-fields

匆匆过客 提交于 2020-03-18 12:30:28
问题 I have come across a strange behavior on signed bit-fields: #include <stdio.h> struct S { long long a31 : 31; long long a32 : 32; long long a33 : 33; long long : 0; unsigned long long b31 : 31; unsigned long long b32 : 32; unsigned long long b33 : 33; }; long long f31(struct S *p) { return p->a31 + p->b31; } long long f32(struct S *p) { return p->a32 + p->b32; } long long f33(struct S *p) { return p->a33 + p->b33; } int main() { struct S s = { -2, -2, -2, 1, 1, 1 }; long long a32 = -2;

How can I install openMP on my new MacBook Pro (with Mac OS Catalina)?

跟風遠走 提交于 2020-03-14 05:21:42
问题 I installed Xcode (and also the command line tools) but terminal says (when I'm compiling): gcc -o task -fopenmp task.c clang: error: unsupported option '-fopenmp' I tried to install openmp via brew but people say that it's not available anymore on homebrew, they suggest to try brew instal llvm But I get the same error. I tried also in the boneyard brew install homebrew/boneyard/clang-omp but the repository doesn't exist anymore. Could you help me? I just need to learn openMP, I don't think