Lub ntsuas ntsuas muaj qhov "standard" xaiv -j, tso cai rau kev txheeb xyuas kom ua tiav nyob rau hauv tib lub sijhawm hauv ntau txoj haujlwm. Qhov no txuag tau ntau lub sijhawm.
Hmoov tsis zoo, PVS qee zaum ua yuam kev syntax thiab tsim cov lus tsis raug zoo thaum cov cai yog tag nrho.
Piv txwv li, muaj ib txoj haujlwm uas rov qab los void:
template <typename T>
auto copy (const void * source, void * destination)
->
std::enable_if_t
<
std::is_copy_constructible<T>::value
>
{
new (destination) T(*static_cast<const T *>(source));
}
Yog yog lo lus tseem ceeb auto txhais tau tias void, yog qhov nws yog rau pib. Tab sis PVS tau tsim cov lus hauv qab no:
dynamic_tuple_management.hpp:29:1: error: V591 Non-void function should return a value.
dynamic_tuple_management.hpp:29:1: error: V2542 Function with a non-void return type should return a value from all exit paths.
Nws yog qhov tsis yooj yim rau kev ua haujlwm nrog qib kev kuaj mob ntawm lub console
Cia peb pib nrog qhov tseeb tias ob lo lus txib siv (qhov no pvs-studio-analyzer ΠΈ plog-converter) txawv hom ntawv rau kev txheeb xyuas.
Pab rau pvs-studio-analyzer nyeem:
-a [MODE], --analysis-mode [MODE]
MODE defines the type of warnings:
1 - 64-bit errors;
2 - reserved;
4 - General Analysis;
8 - Micro-optimizations;
16 - Customers Specific Requests;
32 - MISRA.
Modes can be combined by adding the values
Default: 4
Kuv siv sijhawm ntev los sim seb yuav mus qhov twg ntxiv (βntxiv cov nqiβ) cov yuam sij. Kuv sim sau lawv cais los ntawm commas:
pvs-studio-analyzer analyze ... -a 1,4,16
Kuv sim sau npe tus yuam sij ob peb zaug:
pvs-studio-analyzer analyze ... -a 1 -a 4 -a 16
Thiab tsuas yog tom qab ntawd kuv puas paub tias cov no yog qhov ncauj qhov ntswg me ntsis! Thiab koj xav tau ua sumthiab tsis ntxiv lub ntsiab lus. Piv txwv li, kom tau txais kev kuaj mob dav dav, kev kuaj mob rau micro-optimizations thiab MISRA, koj yuav tsum suav lawv (4 + 8 + 32 = 44):
pvs-studio-analyzer analyze ... -a 44
Kev siv bitmasks hauv cov neeg siv interfaces feem ntau yog daim ntawv tsis zoo. Tag nrho cov no tuaj yeem suav nrog sab hauv, thiab teeb tsa chij tuaj yeem teeb tsa rau tus neeg siv.
Tsis tas li ntawd, kuj muaj kev siv hluav taws xob plog-converter, uas generates human-readable static tsom xam cov ntaub ntawv. Nws muaj lwm yam teeb meem.
PVS tsis pom muaj kab mob tiag tiag hauv kuv qhov chaw qhib Tawg nthe ΠΈ Ntxiv mus, raws li nyob rau hauv ib daim ntawv ua haujlwm, uas, vim li cas, kuv tsis tuaj yeem nthuav tawm. Muaj tseeb, nws tsim nyog nco ntsoov tias qee qhov kev tsis txaus ntseeg tau raug ntes thiab kho ua ntej siv Cppcheck ΠΈ scan-build.
Feem ntau, qhov kev xav los ntawm tag nrho cov kev ntsuas no yog kwv yees li qub: yog, lawv ntes ib yam dab tsi, qee zaum txawm tias ib qho tseem ceeb, tab sis tag nrho cov compiler txaus.
Nws yog qhov ua tau (thiab kuv tus kheej nyiam xav li ntawd) uas peb pab neeg siv software txhim kho kev coj ua uas tso cai rau peb los tsim qhov tsawg kawg nkaus ntawm shitty code. Nws yog qhov zoo dua tsis txhob tsim teeb meem ntau dua li kev kov yeej lawv tus kheej.
Yog li ntawd, kuv muaj kev ywj pheej ntawm kev muab qee cov lus qhia txog yuav ua li cas sau hauv C ++ hauv txoj hauv kev xws li tsis txhob tua leej twg ob txhais ceg tawm lossis ntaus ib tus neeg hauv pliaj nrog lub rake.
Ua qhov feem ntau ntawm kev kuaj xyuas compiler
Peb pab neeg siv (thiab qhia rau koj) cov kev xaiv muab tso ua ke hauv qab no: