Skip to content

Commit b1ac3ff

Browse files
committed
Merge branch 'topic/preprocessing_doc' into 'master'
Add documentation about source pre-processing Closes #433 See merge request eng/libadalang/langkit-query-language!394
2 parents 4fe1d78 + 2189043 commit b1ac3ff

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

+40
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,46 @@ GNATcheck:
392392
there is no applicable ``Switches`` attribute.
393393

394394

395+
.. _Source_Preprocessing:
396+
397+
Sources pre-processing
398+
======================
399+
400+
GNATcheck is handling Ada sources pre-processing, meaning that sources lines
401+
that are "excluded" by the Ada pre-processor are also ignored during the
402+
GNATcheck analysis. For example, given the following source:
403+
404+
.. code-block:: ada
405+
406+
procedure Main is
407+
begin
408+
# if Foo = "Bar" then
409+
goto lbl;
410+
# else
411+
null;
412+
# end if;
413+
end Main;
414+
415+
Running GNATcheck with the ``Goto_Statements`` rule enabled on this Ada code
416+
will flag the ``goto lbl;`` if, and only if, the preprocessor symbol ``Foo``
417+
is set to ``"Bar"``.
418+
419+
To configure pre-processing, you can use the following GPR attributes:
420+
421+
* ``Builder.Global_Compilation_Switches``
422+
* ``Builder.Default_Switches``
423+
* ``Builder.Switches``
424+
* ``Compiler.Default_Switches``
425+
* ``Compiler.Switches``
426+
427+
.. attention::
428+
429+
There is a limitation to the GNATcheck's pre-processing handling regarding
430+
conditioned ``with`` clauses. Meaning that no matter how symbols are defined,
431+
all ``with`` clauses are going to be analyzed and used by GNATcheck to
432+
resolve the closure of files to analyze.
433+
434+
395435
.. _LKQL_options_file:
396436

397437
LKQL Rule Files

0 commit comments

Comments
 (0)