aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorQiu Chaofan <qcf@ecnelises.com>2025-03-29 01:54:14 +0800
committerGitHub <noreply@github.com>2025-03-29 01:54:14 +0800
commitb3f01a6aa45b00240cec1c64286b85d7ba87e2af (patch)
treea56db37aa87cb9ed2b27750bac0efaa01a73e194 /clang/lib/Frontend/FrontendAction.cpp
parente70fe9b264b6f98fd3744b514d7166f75dd19872 (diff)
downloadllvm-b3f01a6aa45b00240cec1c64286b85d7ba87e2af.zip
llvm-b3f01a6aa45b00240cec1c64286b85d7ba87e2af.tar.gz
llvm-b3f01a6aa45b00240cec1c64286b85d7ba87e2af.tar.bz2
[Clang] Check PP presence when printing stats (#131608)
Front-end option `-print-stats` can be used to print statistics around the compilation process. But clang with this options will crash when input is IR file. This patch fixes the crash by checking preprocessor presence before invoking it.
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index f6ad7c8..2d77f06 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -1074,10 +1074,14 @@ void FrontendAction::EndSourceFile() {
if (CI.getFrontendOpts().ShowStats) {
llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFileOrBufferName() << "':\n";
- CI.getPreprocessor().PrintStats();
- CI.getPreprocessor().getIdentifierTable().PrintStats();
- CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
- CI.getSourceManager().PrintStats();
+ if (CI.hasPreprocessor()) {
+ CI.getPreprocessor().PrintStats();
+ CI.getPreprocessor().getIdentifierTable().PrintStats();
+ CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
+ }
+ if (CI.hasSourceManager()) {
+ CI.getSourceManager().PrintStats();
+ }
llvm::errs() << "\n";
}