Enabling UE4 Static Analysis#
Manually through UE4#
- Pass
-StaticAnalyzer=VisualCPP
(or PVSStudio) to UBT.exe build - Make sure to Do full build of project (clean then build)
- Also make sure to disable XGE
- Can also modify buildconfiguration.xml
XML<WindowsPlatform> <StaticAnalyzer>VisualCpp</StaticAnalyzer> <!-- <StaticAnalyzer>PVSStudio</StaticAnalyzer> --> </WindowsPlatform>
Devops script#
Bash
build.py bbr --analyzer=PVSStudio
UBT Command line#
Bash
UnrealBuildTool.exe UE4Editor Win64 Development -staticanalyzer=pvsstudio
UnrealBuildTool.exe UE4Editor Win64 Development -staticanalyzer=visualcpp -nodebuginfo
(Reference)
Manually setting up PVS Studio for Static Analysis#
- Download PVS Studio
- Launch standalone.exe, go to
Tools->Options->Registration
- Name: PVS-Studio Free
- Key: FREE-FREE-FREE-FREE
- Add the following comments to every .cpp file
C++// This is an independent project of an individual developer. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
- for now, you need to have Incredibuild disabled
- go to BBProto.Build.cs and add
BuildConfiguration.bAllowXGE = false;
- Open a shell in the PVS Studio folder and run
CLMonitor.exe monitor
- Do a full build of BBProto project
- Go back to the shell, and type
CLMonitor.exe analyze -l "sample.plog"
- Double clicking sample.plog should launch the analysis results in PVS Studio