diff options
author | ziqingluo-90 <ziqing@udel.edu> | 2023-05-12 11:45:44 -0700 |
---|---|---|
committer | ziqingluo-90 <ziqing@udel.edu> | 2023-05-12 11:50:51 -0700 |
commit | 6d861d498de1320d22771c329ec69f9419ef06b7 (patch) | |
tree | ae9bb2badd8a91ab9dd11b9f0a9ff10c7f39437c /clang/include | |
parent | 1644adfc74b4bde822b37398b3811f038073d9a9 (diff) | |
download | llvm-6d861d498de1320d22771c329ec69f9419ef06b7.tar.gz |
[-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit
The unsafe-buffer analysis requires a complete view of the translation
unit (TU) to be conservative. So the analysis is moved to the end of a
TU.
A summary of changes made: add a new `IssueWarnings` function in
`AnalysisBasedWarnings.cpp` for TU-based analyses. So far
[-Wunsafe-buffer-usage] is the only analysis using it but there could
be more. `Sema` will call the new `IssueWarnings` function at the end
of parsing a TU.
Reviewed by: NoQ (Artem Dergachev)
Differential revision: https://reviews.llvm.org/D146342
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Sema/AnalysisBasedWarnings.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h b/clang/include/clang/Sema/AnalysisBasedWarnings.h index 13a88bb9f896..c73506894db9 100644 --- a/clang/include/clang/Sema/AnalysisBasedWarnings.h +++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H #define LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H +#include "clang/AST/Decl.h" #include "llvm/ADT/DenseMap.h" #include <memory> @@ -95,6 +96,9 @@ public: void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType); + // Issue warnings that require whole-translation-unit analysis. + void IssueWarnings(const TranslationUnitDecl *D); + Policy getDefaultPolicy() { return DefaultPolicy; } void PrintStats() const; |