COP 3402 meeting -*- Outline -*- * Overview of Static Analysis ** Goals for Static Analysis for a Compiler ------------------------------------------ GOALS FOR STATIC ANALYSIS - Protect code generator from extra cases - Catch problems, to improve programmer productivity - Gather information to improve programs ------------------------------------------ ... e.g., cases that are not defined for the language ... e.g., use of a variable before it is assigned, computations whose value can't ever be used ... e.g., what does the value of each variable depend on? (which can help move code out of loops) Q: What does static mean? Before runtime Q: Where would type checking fit in here? Catching problems, avoid headaches in debugging *** Kinds of problems to catch: ------------------------------------------ PROBLEMS TO CATCH ------------------------------------------ ... - inconsistencies, in general - type errors - violations of the language's semantic rules e.g., undeclared identifiers obviously wrong casts that will fail incomplete analysis of cases in a switch-like statement - obviously useless code (e.g., code that can't be executed ever, code that has a value that can never be used) Q: How could these problems help the programmer? the programmer thought about something in 2 different ways, probably one of them is wrong e.g., calling a function with a different number of arguments than are in the implementation