Out of Sight, Out of Place: Detecting and Assessing Swapped Arguments

Originally published on IEEE.org

20th IEEE International Working Conference on Source Code Analysis and Manipulation, SCAM 2020, Adelaide, Australia, September 28 – October 2, 2020


Roger Scott, Joseph Ranieri, Lucja Kot and Vineeth Kashyap


Programmers often add meaningful information about program semantics when naming program entities such as variables, functions, and macros. However, static analysis tools typically discount this information when they look for bugs in a program. In this work, we describe the design and implementation of a static analysis checker called SWAPD, which uses the natural language information in programs to warn about mistakenly-swapped arguments at call sites. SWAPD combines two independent detection strategies to improve the effectiveness of the overall checker. We present the results of a comprehensive evaluation of SWAPD over a large corpus of C and C++ programs totaling 417 million lines of code. In this evaluation, SWAPD found 154 manually-vetted real-world cases of mistakenly-swapped arguments, suggesting that such errors- while not pervasive in released code-are a real problem and a worthwhile target for static analysis.

Contact Us

Get a personally guided tour of our solution offerings. 

Contact US