Blog

Posts Tagged ‘Parse’

Creating Accurate C/C++ Projects

Tuesday, October 30th, 2012

Last year I posted about Improving Project Accuracy for C/C++ projects. Since then, we have released several new features that make it easier to get accurate project definitions.

Why do I care?

The more information Understand has about include paths and macro configuration, the more closely your Understand project will match your compiled code. In most cases, Understand does a great job of parsing the code and figuring out what goes where, but sometimes there are things you don’t expect in your project.

Some symptoms the project configuration may need to be improved:

1. Chunks of inactive (pink) code that should be getting parsed but are not:

image

2. The same entity shows up multiple times, with some of those definitions unresolved(gray)

imageimage

3. Missing entities in graphs

image

Strict or Fuzzy Parsing

image

Understand now let’s you chose between two different types of parsing when creating C/C++ projects. The fuzzy parse is not as accurate but is great if the code doesn’t compile or for making an initial pass of the project with Understand. The strict parser requires that the include paths and macros be setup correctly, as outlined below, but in return will provide a very accurate parse. Objective-C and Objective-C++ both require the strict parser. Also if your project makes heavy use of C++ or Overloaded functions you will want to use the Strict Parser.

image

Choose Compiler Options

It’s important to double check the Compiler Options and make sure they are set correctly. By configuring the right Compiler details, many Macros, Pragmas and Include Paths are automatically added to the project and increase the accuracy. These settings are accessed under Project->Configure Project->C++ or C++(Strict)

image

Automatically Set Includes and Macros

Depending on your build system, Understand may be able to extrapolate the Include and Macro information automatically.


Visual Studio

If you use Visual Studio, you can specify the Visual Studio solution or project files directly and Understand will gather all the information from them.  Those files can be specified during the Project Creation wizard or in Project->Configure Project->Visual Studio.

GCC/G++

If your project builds with GCC or G++, you can use the new Buildspy feature to hook into the build system and gather the correct data for the Understand project.  More details on configuring Buildspy here, or there is a video here to get you started.

CMake

If your team uses the cross-platform build system, CMake, follow the directions here to create an Understand project as it compiles.

Manually Setting Includes and Macros

If your project doesn’t support any of the above options, you can manually configure the Includes and Macros for the project. We’ve added a couple of new tools to identify the missing bits and make this process more intuitive.

Missing Includes

Missing include directories can be added in Project->Configure Project->C++->Includes. The new "Search" button opens a dialog that let’s you quickly identify where the missing search files are and add those directories to the include paths for your project.

image

Missing Macros

Similarly, Missing Macros can be added via Project->Configure Project->C++->Macros.  The new "Undefined Macros" button opens a dialog that will let you quickly identify macros that may be missing from the project and you can specify their definitions.

image

Overrides

In some cases, individual files or directories have their own macros and include paths that are different from other parts of the project. These can be specified by going to the file or folder in question in Project->Configure Project->Files. Right click on it, and select Configure override settings. From that dialog you can add the specifics.

image

Conclusion

Understand does a great job of parsing projects "out of the box" but if the project is more complex, there are a lot of options for adding more detail to the project configuration and ending up with a perfect analysis.

C++ Template and Overload Support (Beta)

Wednesday, October 12th, 2011

screenshot.15

Many users have asked us in the past if Understand could have better support for Templates and Overloaded functions. We are excited to announce that this is now a reality. Our engineers have worked hard to add a completely new C++ parser to Understand, which is available for Beta testing in build 586.

Our current C++ parser was written with the goal of being able to use fuzzy logic to handle incomplete, non-compiling code gracefully and as accurately as possible. It does a great job at that and will continue to be an important part of our toolset. Unfortunately that same feature caused severe difficulties in parsing templates and recognizing overloaded functions.  The new parser is more strict than the old parser and requires a more accurate project definition. If you plan on using it, please follow the instructions from this post to ensure your project is as correct as possible:  Improving Project Accuracy (C/C++)

To access the new parser, just check the new checkbox on the Languages screen when creating a new project or in the Project Configuration dialog.

We welcome and appreciate your feedback and comments on this new parser – please send it to us at support@scitools.com

Improving Project Accuracy (C/C++)

Friday, September 16th, 2011

Usually just identifying the root of your source tree and saying "Analyze" will provide you with a accurate, useful Understand project. Sometimes, however, you need a more accurate representation of your project. Maybe you have large swaths of inactive code that should be enabled, maybe there are grayed out (unresolved) entities that do exist in the source code, or maybe the metrics don’t seem to line up. In cases like this, you will want to use some of the advanced C++ options to fine tune the parse. Here are some things that will improve the parse accuracy.

(more…)

Parse Improvement Tool

Tuesday, April 5th, 2011

Improve Parse With Understand 2.6 Build 560 we’ve added a powerful new tool for creating C/C++ projects. The Parse Improvement Tool helps you quickly find missing include paths for your project which will lead to more accurate parsing and project information. Previously Understand relied on you knowing exactly where the include files were and specifying the path. Now there is a tool to help you find those missing files.

(more…)