Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Using the source viewer in Klocwork Static Code Analysis

Using the source viewer in Klocwork Static Code Analysis

The source viewer is a powerful tool for investigating detected issues in Klocwork Static Code Analysis. It displays source code with line numbers, syntax highlighting, and menus so that you can easily understand and navigate through your source code.

Accessing the source viewer

There are two ways you can access the source viewer:

  • To view source for an issue, click an issue description in the issue list.
  • To view source from within Source-Cross Reference, click xref in the component bar, navigate to an entity you want to look at and click the Source Code tab in the view.
    Note: The Source Code tab is only visible if there's source code available for the selected entity.

Using the source viewer

Functions in the source viewer are collapsed by default--except of course the one that contains the issue you're viewing. You can expand functions individually or all at once by using the expand or collapse buttons above the source viewer.

When assessing detected issues, it's handy to be able to track how an entity, such as a variable, is used across functions or the entire file. The source viewer has a search field in the upper right corner.

When you click an unknown (unhyperlinked) entity, such as a variable, your selection automatically populates the search field and each instance is highlighted in orange in the file. Orange markers in the right margin indicate each entity instance in the file.

If a whole line of code is highlighted in orange, it indicates that matching instances of the entity are located in the folded function. Expand the function to see additional entity search results.

You can navigate to each instance of the entity with these orange markers or with the previous and next arrows next to the search field.

Entity highlighting in the Source Viewer works only for single words. Multi-word entity search highlighting is not supported.

Tip: A + symbol in the search field indicates a full word match search.

Red markers indicate detected issues in the current file:

Note: These red markers will not appear in the Source-Cross Reference source viewer.

Types (such as char, int, class, and this) and keywords (such as const, static, return, while, and if) appear in dark blue.

Preprocessor directives such as includes and defines are in dark red. Click the green include file link to navigate to the file.

Investigating known entity identifiers

Known entity identifiers (such as file and class identifiers) appear in blue. Clicking the blue text opens a pop-up menu:

Options in the pop-up menu allow you to:

  • Show Declaration- see where the entity was declared in the source file
  • Show Implementation- see where the entity was implemented
  • Source-Cross Reference- expand your view to see where the entity is used across the program
  • Show usage- see where the entity is referenced
Note: When you click Show Implementation or Show Declaration in the pop-up menu, the line in the source code where the entity is implemented or declared will appear with the line number highlighted in blue (clicking source cross-reference displays the entity's details in the right pane).
  • Find in file- populates the search field and each instance is highlighted in the file in the same manner as described above