[PATCH] D155802: [clang][dataflow] Print the source line if we saw unexpected diagnostics in tests.
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 05:40:41 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b5d3ba829c1: [clang][dataflow] Print the source line if we saw unexpected diagnostics in… (authored by mboehme).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155802/new/
https://reviews.llvm.org/D155802
Files:
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===================================================================
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -12,6 +12,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/SourceLocation.h"
+#include "clang/Frontend/TextDiagnostic.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
@@ -1334,7 +1335,17 @@
auto &SrcMgr = AO.ASTCtx.getSourceManager();
llvm::DenseSet<unsigned> DiagnosticLines;
for (SourceLocation &Loc : Diagnostics) {
- DiagnosticLines.insert(SrcMgr.getPresumedLineNumber(Loc));
+ unsigned Line = SrcMgr.getPresumedLineNumber(Loc);
+ DiagnosticLines.insert(Line);
+ if (!AnnotationLines.contains(Line)) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(
+ new DiagnosticOptions());
+ TextDiagnostic TD(llvm::errs(), AO.ASTCtx.getLangOpts(),
+ DiagOpts.get());
+ TD.emitDiagnostic(
+ FullSourceLoc(Loc, SrcMgr), DiagnosticsEngine::Error,
+ "unexpected diagnostic", std::nullopt, std::nullopt);
+ }
}
EXPECT_THAT(DiagnosticLines, ContainerEq(AnnotationLines));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155802.542458.patch
Type: text/x-patch
Size: 1521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230720/500ec431/attachment-0001.bin>
More information about the cfe-commits
mailing list