English 中文(简体)
C++:静态分析代码(和/或先处理)的工具[封闭]
原标题:C++: tools to statically analyze code (and/or preprocess it) [closed]

问我们 提议或找到一种工具、图书馆或偏袒场外资源的问题,在Stack Overflow,因为它们往往吸引有意见的答复和垃圾邮件。 相反, 问题以及迄今为止为解决这一问题所做的工作。

Closed 9 years ago.

我常常可以使用一些工具静态分析我的守则,以帮助我使其更清洁。 有时像汇编者警告,但还不够。 现在,我梦想撰写一份书(使用部族图书馆或乐施会),但我猜测,会做太多的工作。

我所想的一些事情是:

  1. 寻找神学院的数字(即硬编码常数不同于0)。

  2. 检查三条规则始终得到遵守(每个班级都必须界定所有司机、复印机和派任操作员,或其中无一人)。


我也梦想(但这些事情只是乌托皮阿),涉及一个前处理器,使某些非标准法典化,将其转化为有效的C++代码,这一工具能够:

  1. 扩大模板,以便我能够在C++中找到(现在,不再需要C++0x)

  2. 在档案结尾处转站职能,以便我不必遵守申报前的规则,并且能够像在 Java那样写班级。

  3. 提供一幅长.,如支持海关操作员(在职能电话中将扩大),或一些临时代号/关键词,以便于实施某些模式。


在那里是否有任何工具,能够做这些事情的一小部分?

否则,你会建议哪些图书馆执行这些任务(地兰校准、格凯尔),以及你认为需要多少工作?

最佳回答

cppcheck is just wonderful.

问题回答

clang可作静态分析。

关于定点,我们。 SD 来源法搜索引擎(SCSE)可在大陆架外进行。 高等专业资格考试委员会提供全球调查接口,以检索大量混合编程式的地毯,使用准确理解每种语文的体格语。

典型查询:

 for  ... I=index*  =  N<10

will find for keywords near an Identifier whose name must start with the sequence index followed immediately by an = operator followed by a Number whose value is less than 10. Because SCSE understands the language structure, it isn t bothered by whitespace or formatting constraints. It will also match hexadecimal values for N; it understands the different format for literals and offers queries in terms of the actual value of the number, rather than as a string.

鉴于这种问询,全球调查股将发现所有与你的所有档案相匹配之处,并显示一系列的点击;点击一个点击了你的源代码,并着重提到点击线。

为了找到所有零不变的固定点,你写道:

N>0

What you really want are all constants that aren t defined in some kind of constant definition. So you want to remove any constant-definitions from the hit list, which is accomplished by using the "query subtract" operator:

N>0 -   const   int  I  =  N

由此可见的是非零不变的,并且删除了也与最接近的声明相匹配的任何东西。


Your other dreams require a much more sophisticated engine. In essence, you want to analyze C++ code (your rule of three) or extend the C++ language with some new features, and then implement those features using standard C++ capabilities. You can accomplish this using a program transformation system that can manipulate C++.

http://www.semantic Designs.com/Products/DMS/DMSToolkit.html DMS 软件再设计能够做到这一点。 它拥有一个完整的 rel=“nofollow”>C++ front end,规定C++为内部汇编数据结构,并编制完整的编号表(并可重新编制C++来源代码,并附上其内部结构的所有细节)。 借助这一前端和基于配对模式的联几支助处,你可以进行三驾.。

在语言推广方面,你可以修改地图,把你认为理想的外围建筑包括在内,从而修改数字管理系统C++前端。 然后,你可以写出计划转变,看着这种结构,并将它们转化为理想的法典。 (这一想法被称作intentional program,由Charles SimyoniMS of fame,但只是方案转变的一个特殊案例。)

DMS has been used to carry out massive automated transformations on real C++ applications. It could do your task fairly easily from a technical point of view. However, understanding the definition of C++ and how everything fits together, and how DMS supports transformations, requires considerable compiler-style sophistication. What you suggest to do isn t an afternoon or a week s worth of work. It would take a significant investment in education and effort. But a lot less than trying to do with starting with just YACC.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签