Skip to content

Commit 3d09f25

Browse files
Make 3c -verify an error for now.
PR #488 made `3c -verify` verify only the compiler diagnostics, but none of our regression tests actually use that functionality. Instead, one regression test (macro_function_call) used `3c -verify` to try to test the absence of 3C warnings, and we were unaware that the test wasn't testing what it was supposed to. I think it's best to make `3c -verify` an error for now so we don't make that mistake again. I'm deleting the addVerifyAdjuster code because I think we're unlikely to ever want to use it. If we do, it should be easy enough to bring back by reverting this commit.
1 parent 0a06522 commit 3d09f25

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

clang/lib/3C/3C.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ ArgumentsAdjuster getIgnoreCheckedPointerAdjuster() {
8585
return AdjustedArgs;
8686
};
8787
}
88-
ArgumentsAdjuster addVerifyAdjuster() {
89-
return [](const CommandLineArguments &Args, StringRef /*unused*/) {
90-
CommandLineArguments AdjustedArgs(Args);
91-
if (std::find(AdjustedArgs.begin(),AdjustedArgs.end(),"-verify")
92-
== AdjustedArgs.end()) {
93-
AdjustedArgs.push_back("-Xclang");
94-
AdjustedArgs.push_back("-verify");
95-
}
96-
return AdjustedArgs;
97-
};
98-
}
9988

10089
void dumpConstraintOutputJson(const std::string &PostfixStr,
10190
ProgramInfo &Info) {
@@ -186,6 +175,13 @@ _3CInterface::_3CInterface(const struct _3COptions &CCopt,
186175

187176
ConstraintsBuilt = false;
188177

178+
if (VerifyDiagnosticOutput) {
179+
errs() << "3C initialization error: Diagnostic verification is currently "
180+
"unsupported.\n";
181+
Failed = true;
182+
return;
183+
}
184+
189185
if (OutputPostfix != "-" && !OutputDir.empty()) {
190186
errs() << "3C initialization error: Cannot use both -output-postfix and "
191187
"-output-dir\n";
@@ -287,11 +283,6 @@ bool _3CInterface::parseASTs() {
287283

288284
auto *Tool = new ClangTool(*CurrCompDB, SourceFiles);
289285
Tool->appendArgumentsAdjuster(getIgnoreCheckedPointerAdjuster());
290-
// TODO: This currently only enables compiler diagnostic verification.
291-
// see https://github.com/correctcomputation/checkedc-clang/issues/425
292-
// for status.
293-
if (VerifyDiagnosticOutput)
294-
Tool->appendArgumentsAdjuster(addVerifyAdjuster());
295286

296287
// load the ASTs
297288
return !Tool->buildASTs(ASTs);

clang/test/3C/macro_function_call.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: rm -rf %t*
2-
// RUN: 3c -base-dir=%S -verify -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
3-
// RUN: 3c -base-dir=%S -verify -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
4-
// RUN: 3c -base-dir=%S -verify -alltypes -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
5-
// RUN: 3c -base-dir=%S -verify -alltypes -output-dir=%t.checked %s --
6-
// RUN: 3c -base-dir=%t.checked -verify -alltypes %t.checked/macro_function_call.c -- | diff %t.checked/macro_function_call.c -
2+
// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
3+
// RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
4+
// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
5+
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
6+
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/macro_function_call.c -- | diff %t.checked/macro_function_call.c -
77

88
// Test fix for https://github.com/correctcomputation/checkedc-clang/issues/439
99
// We cannot insert casts on function calls inside macros, so constraints must
@@ -12,6 +12,13 @@
1212

1313
// 3C emits a warning if it fails inserting a cast. Ensure the test fails if
1414
// this happens.
15+
//
16+
// NOTICE: This part of the test is disabled (the -verify option has been
17+
// removed from the 3c RUN commands) until we have a replacement for the
18+
// diagnostic verifier
19+
// (https://github.com/correctcomputation/checkedc-clang/issues/503).
20+
// TODO: Re-enable it when we do.
21+
//
1522
// expected-no-diagnostics
1623

1724
// Unsafe call in macro. This would require an _Assume_bounds_cast, but we

0 commit comments

Comments
 (0)