[all-commits] [llvm/llvm-project] 1a42f7: [clang][dataflow] Don't analyze templated declarat...
martinboehme via All-commits
all-commits at lists.llvm.org
Mon May 15 04:05:08 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1a42f795587b9d57291d009989aace6efd0a7a7f
https://github.com/llvm/llvm-project/commit/1a42f795587b9d57291d009989aace6efd0a7a7f
Author: Martin Braenne <mboehme at google.com>
Date: 2023-05-15 (Mon, 15 May 2023)
Changed paths:
M clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
M clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
M clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
M clang/lib/Analysis/FlowSensitive/Transfer.cpp
M clang/unittests/Analysis/FlowSensitive/TestingSupport.h
M clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
M clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
Log Message:
-----------
[clang][dataflow] Don't analyze templated declarations.
Attempting to analyze templated code doesn't have a good cost-benefit ratio. We
have so far done a best-effort attempt at this, but maintaining this support has
an ongoing high maintenance cost because the AST for templates can violate a lot
of the invariants that otherwise hold for the AST of concrete code. As just one
example, in concrete code the operand of a UnaryOperator '*' is always a prvalue
(https://godbolt.org/z/s3e5xxMd1), but in templates this isn't true
(https://godbolt.org/z/6W9xxGvoM).
Further rationale for not analyzing templates:
* The semantics of a template itself are weakly defined; semantics can depend
strongly on the concrete template arguments. Analyzing the template itself (as
opposed to an instantiation) therefore has limited value.
* Analyzing templates requires a lot of special-case code that isn't necessary
for concrete code because dependent types are hard to deal with and the AST
violates invariants that otherwise hold for concrete code (see above).
* There's precedent in that neither Clang Static Analyzer nor the flow-sensitive
warnings in Clang (such as uninitialized variables) support analyzing
templates.
Reviewed By: gribozavr2, xazax.hun
Differential Revision: https://reviews.llvm.org/D150352
More information about the All-commits
mailing list