From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 46B7F3856DCA for ; Tue, 9 Aug 2022 15:38:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46B7F3856DCA Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-f2qIGo7zMceBY0m1Vkfscg-1; Tue, 09 Aug 2022 11:38:29 -0400 X-MC-Unique: f2qIGo7zMceBY0m1Vkfscg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12B5529AA2EB for ; Tue, 9 Aug 2022 15:38:28 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.16.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E161BC15BA1; Tue, 9 Aug 2022 15:38:27 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Subject: [committed] docs: add notes on which functions -fanalyzer has hardcoded knowledge of Date: Tue, 9 Aug 2022 11:38:25 -0400 Message-Id: <20220809153825.3031775-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2022 15:38:31 -0000 Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2003-g16877cc2006ede. gcc/ChangeLog: * doc/invoke.texi (Static Analyzer Options): Add notes on which functions the analyzer has hardcoded knowledge of. Signed-off-by: David Malcolm --- gcc/doc/invoke.texi | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 92f7aaead74..a17c059d515 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10281,6 +10281,87 @@ See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Unini @end table +The analyzer has hardcoded knowledge about the behavior of the following +memory-management functions: + +@itemize @bullet +@item @code{alloca} +@item The built-in functions @code{__builtin_alloc}, +@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, +@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, +@code{__builtin_memcpy_chk}, @code{__builtin_memset}, +@code{__builtin_memset_chk}, @code{__builtin_realloc}, +@code{__builtin_stack_restore}, and @code{__builtin_stack_save} +@item @code{calloc} +@item @code{free} +@item @code{malloc} +@item @code{memset} +@item @code{operator delete} +@item @code{operator delete []} +@item @code{operator new} +@item @code{operator new []} +@item @code{realloc} +@item @code{strdup} +@item @code{strndup} +@end itemize + +of the following functions for working with file descriptors: + +@itemize @bullet +@item @code{open} +@item @code{close} +@item @code{creat} +@item @code{dup}, @code{dup2} and @code{dup3} +@item @code{read} +@item @code{write} +@end itemize + +of the following functions for working with @code{} streams: +@itemize @bullet +@item The built-in functions @code{__builtin_fprintf}, +@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, +@code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, +@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, +@code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, +@code{__builtin_printf_unlocked}, @code{__builtin_putc}, +@code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, +@code{__builtin_putc_unlocked}, @code{__builtin_puts}, +@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and +@code{__builtin_vprintf} +@item @code{fopen} +@item @code{fclose} +@item @code{fgets} +@item @code{fgets_unlocked} +@item @code{fread} +@item @code{getchar} +@item @code{fprintf} +@item @code{printf} +@item @code{fwrite} +@end itemize + +and of the following functions: + +@itemize @bullet +@item The built-in functions @code{__builtin_expect}, +@code{__builtin_expect_with_probability}, @code{__builtin_strchr}, +@code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, +@code{__builtin_strlen}, @code{__builtin_va_copy}, and +@code{__builtin_va_start} +@item The GNU extensions @code{error} and @code{error_at_line} +@item @code{getpass} +@item @code{longjmp} +@item @code{putenv} +@item @code{setjmp} +@item @code{siglongjmp} +@item @code{signal} +@item @code{sigsetjmp} +@item @code{strchr} +@item @code{strlen} +@end itemize + +In addition, various functions with an @code{__analyzer_} prefix have +special meaning to the analyzer, described in the GCC Internals manual. + Pertinent parameters for controlling the exploration are: @option{--param analyzer-bb-explosion-factor=@var{value}}, @option{--param analyzer-max-enodes-per-program-point=@var{value}}, -- 2.26.3