Source Code Annotation for Static Analysis
https://doi.org/10.15514/ISPRAS-2025-37(6)-8
Abstract
This paper describes source code annotations for static analysis. С/C++ attributes and JVM annotations are considered. Primary goals and reasons for source code annotation for static analysis are given. Main implementation aspects of annotations in Svace static analyzer are described.
Keywords
About the Authors
Vitaly Olegovich AFANASYEVRussian Federation
Postgraduate student at ISP RAS. Research interests: compiler technologies, static analysis, JVM languages.
Alexey Evgenevich BORODIN
Russian Federation
Cand. Sci. (Phys.-Math.), researcher at ISP RAS. Research interests: static analysis for finding errors in source code.
Evgeny Alexandrovich VELESEVICH
Russian Federation
Researcher at ISP RAS. Research interests: compiler technologies.
Boris Viktorovich ORLOV
Russian Federation
Student at the Faculty of Computational Mathematics and Cybernetics of Lomonosov Moscow State University, researcher at ISP RAS. Research interests: compiler technologies, static analysis.
References
1. Иванников В. П., Белеванцев А. А., Бородин А. Е., Игнатьев В. Н., Журихин Д. М., Аветисян А. И., Леонов М. И. Статический анализатор Svace для поиска дефектов в исходном коде программ. Труды ИСП РАН, том 26, вып. 1, 2014 г., стр. 231-250. DOI: 10.15514/ISPRAS-2014-26(1)-7.
2. Бородин А. Е., Белеванцев А. А. Статический анализатор Svace как коллекция анализаторов разных уровней сложности. Труды ИСП РАН, том 27, вып. 6, 2015 г., стр. 111-134. DOI: 10.15514/ISPRAS-2015-27(6)-8.
3. GNU Compiler Collection. Attribute Syntax. Английский. URL: https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html (дата обращения 16.04.2025).
4. __declspec | Microsoft Learn. Английский.
5. URL: https://learn.microsoft.com/en-us/cpp/cpp/declspec?view=msvc-170 (дата обращения 16.04.2025).
6. LLVM Compiler Infrastructure. Английский. URL: https://llvm.org/docs/LangRef.html (дата обращения 16.04.2025).
7. Gosling J., Joy B., Steele G., Bracha G., Buckley A., Smith D., Bierman G. The Java® Language Specification. Java SE 21 Edition. 2023 г.
8. Java SE 21. Interface Plugin. Английский. URL: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.compiler/com/sun/source/util/Plugin.html (дата обращения 15.04.2025).
9. Java SE 21. Interface Processor. Английский. URL: https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/annotation/processing/Processor.html (дата обращения 15.04.2025).
10. The Java™ Tutorials. Trail: The Reflection API. Английский. URL: https://docs.oracle.com/javase/tutorial/reflect/ (дата обращения 15.04.2025).
11. Kotlin Symbol Processing API. Английский. URL: https://kotlinlang.org/docs/ksp-overview.html (дата обращения 11.04.2025).
12. kapt compiler plugin. Английский. URL: https://kotlinlang.org/docs/kapt.html (дата обращения 11.04.2025).
13. Kotlin. Null safety. Английский. URL: https://kotlinlang.org/docs/null-safety.html (дата обращения 24.04.2025).
14. Android API Reference. GuardedBy. Английский. URL: https://developer.android.com/reference/androidx/annotation/GuardedBy (дата обращения 22.04.2025).
15. International Standard ISO/IEC 14882:2024(E) – Programming Language C++. 2024 г.
16. Меркулов А. П., Поляков С. А., Белеванцев А. А. Анализ программ на языке Java в инструменте Svace. Труды ИСП РАН, том 29, вып. 3, 2017 г., стр. 57-74. DOI: 10.15514/ISPRAS-2017-29(3)-5.
17. Афанасьев В. О., Поляков С. А., Бородин А. Е., Белеванцев А. А. Kotlin с точки зрения разработчика статического анализатора. Труды ИСП РАН, том 33, вып. 6, 2021 г., стр.67-82. DOI: 10.15514/ISPRAS-2021-33(6)-5.
18. Афанасьев В. О., Бородин А. Е., Белеванцев А. А. Статический анализ для языка Scala. Труды ИСП РАН, том 36, вып. 3, 2024 г., стр. 9-20. DOI: 10.15514/ISPRAS-2024-36(3)-1.
19. Attributes for null-state static analysis interpreted by the C# compiler. Conditional post-conditions: NotNullWhen, MaybeNullWhen, and NotNullIfNotNull. Английский. URL: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis#conditional-post-conditions-notnullwhen-maybenullwhen-and-notnullifnotnull (дата обращения 14.05.2025).
20. IntelliJ IDEA. Annotations. Английский. URL: https://www.jetbrains.com/help/idea/annotating-source-code.html (дата обращения 15.04.2025).
21. IntelliJ IDEA. Annotations. JetBrains annotations dependency. Английский. URL: https://www.jetbrains.com/help/idea/annotating-source-code.html#jetbrains-annotations (дата обращения 15.04.2025).
22. The Python Standard Library. typing – Support for type hints. Английский. URL: https://docs.python.org/3/library/typing.html (дата обращения 15.04.2025).
23. Van Rossum G., Lehtosalo J., Langa L. Python Enhancement Proposals. PEP 484 – Type Hints. Английский. URL: https://peps.python.org/pep-0484/ (дата обращения 15.04.2025).
24. Mypy: Optional Static Typing for Python. Английский. URL: https://mypy-lang.org/ (дата обращения 15.04.2025).
25. Di Grazia L., Pradel M. The Evolution of Type Annotations in Python: An Empirical Study. Proceedings of the ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE), 2022 г. DOI: 10.1145/3540250.3549114.
26. Clang 21.0.0git documentation. Source Annotations. Английский. URL: https://clang.llvm.org/docs/analyzer/user-docs/Annotations.html (дата обращения 16.04.2025).
27. Evans D., Larochelle D. Improving security using extensible lightweight static analysis. IEEE software, том 19, вып. 1, 2002 г., стр. 42-51. DOI: 10.1109/52.976940.
28. Shankar U., Talwar K., Foster J. S., Wagner D. Detecting format string vulnerabilities with type qualifiers. 10th USENIX Security Symposium (USENIX Security 01), 2001 г.
Review
For citations:
AFANASYEV V.O., BORODIN A.E., VELESEVICH E.A., ORLOV B.V. Source Code Annotation for Static Analysis. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2025;37(6):135-148. (In Russ.) https://doi.org/10.15514/ISPRAS-2025-37(6)-8






