Skip to content

Make 3c -verify an error for now. #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions clang/lib/3C/3C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ _3CInterface::_3CInterface(const struct _3COptions &CCopt,

ConstraintsBuilt = false;

if (VerifyDiagnosticOutput) {
errs() << "3C initialization error: Diagnostic verification is currently "
"unsupported.\n";
Failed = true;
return;
}

if (OutputPostfix != "-" && !OutputDir.empty()) {
errs() << "3C initialization error: Cannot use both -output-postfix and "
"-output-dir\n";
Expand Down Expand Up @@ -287,6 +294,9 @@ bool _3CInterface::parseASTs() {

auto *Tool = new ClangTool(*CurrCompDB, SourceFiles);
Tool->appendArgumentsAdjuster(getIgnoreCheckedPointerAdjuster());
// NOTE: This code is currently unreachable because VerifyDiagnosticOutput is
// rejected in the _3CInterface constructor.
//
// TODO: This currently only enables compiler diagnostic verification.
// see https://github.com/correctcomputation/checkedc-clang/issues/425
// for status.
Expand Down
17 changes: 12 additions & 5 deletions clang/test/3C/macro_function_call.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: rm -rf %t*
// RUN: 3c -base-dir=%S -verify -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
// RUN: 3c -base-dir=%S -verify -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
// RUN: 3c -base-dir=%S -verify -alltypes -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
// RUN: 3c -base-dir=%S -verify -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -verify -alltypes %t.checked/macro_function_call.c -- | diff %t.checked/macro_function_call.c -
// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
// RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/macro_function_call.c -- | diff %t.checked/macro_function_call.c -

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

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

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