Skip to content

Name every unsupported construct in C++ terms; lower C++20 rewritten comparisons - #134

Merged
SwayamInSync merged 8 commits into
mainfrom
fix/construct-names
Oct 29, 2026
Merged

SwayamInSync merged 8 commits into
mainfrom
fix/construct-names

Conversation

@SwayamInSync

Copy link
Copy Markdown
Owner

Plan item E2 (located messages in user terms) and exit criterion 2: "no message names a Clang AST class". The converter named every construct it had no words for by Clang's class (this statement is unsupported (OMPSimdDirective)), and its test said so: "A construct without a name of its own is named by Clang's class".

On the base

$ cpp-verify --lower-only probe.cpp -- -std=c++20 -fopenmp
probe.cpp:7:1: error: simd_sum: this statement is unsupported (OMPSimdDirective)
probe.cpp:13:67: error: atom: this expression is unsupported (AtomicExpr)
probe.cpp:7:33: error: coro: this statement is unsupported (CoroutineBodyStmt)
probe.cpp:4:42: error: elvis: this expression is unsupported (BinaryConditionalOperator)
probe.cpp:6:49: error: rewritten: this expression is unsupported (CXXRewrittenBinaryOperator)
probe.cpp:4:45: error: pseudo: indirect function calls are unsupported

With this PR

error: simd_sum: OpenMP directives are unsupported
error: atom: atomic operations are unsupported: the memory model of threads is not modeled
error: coro: coroutines are unsupported
error: elvis: this expression `x ?: 1` is unsupported
error: pseudo: a destructor call of a scalar is unsupported

and rewritten verifies.

Change

  • Names. unsupportedConstruct names, as C++ does, OpenMP directives (any OMPExecutableDirective), coroutines (co_return, co_await, co_yield, a coroutine body), __try, atomic operations (__atomic_*, AtomicExpr), typeid, dynamic_cast, va_arg, __uuidof, vector and matrix operations, and a pseudo-destructor call (y.Int::~Int(), which was called an indirect call).
  • Quotes. A construct C++ gives no name of its own is quoted from the source instead of named by its Clang class: the first line of its text, at most 40 characters (quotedSource, through the expansion range, so a macro shows its use). No message of the converter names a Clang class now; getStmtClassName has no other use in clang/lib/Verify.
  • Rewritten comparisons. One of the quoted constructs is ordinary C++20, so it is supported instead of named: a comparison rewritten in terms of another operator (a != b with only operator==, which is !(a == b); 5 == r with only R::operator==(int), reversed to r == 5) is converted as its semantic form, the call Clang already built, and checked against that operator's contract. Nothing else about member operators changes: the object must be a reference, an addressable local, or a dereference, as for a == b.

Tests

  • unsupported_constructs.cpp: the OpenMP check now expects its name; new cases for an atomic load, a coroutine, a pseudo-destructor call, and x ?: 1 quoted.
  • suite/rewritten_comparisons.cpp (new): a != b and reversed 5 == r and 5 != r verify; the same with the meaning of == claimed for != fails with a counterexample; rewritten comparisons in a condition and an operand verify.
  • Both fail on main (the base's messages above). Mutants, each caught: the rewritten form not lowered (rewritten_comparisons.cpp), the class name back in the fallback (unsupported_constructs.cpp).
  • The structs page's 19 examples, the new one included, pass check-doc-examples.py.

Docs

  • Structs, "Member operators": rewritten comparisons, with a checked example;
  • limitations (supported functions);
  • release notes ("Errors name the construct, once", and "C++20 rewritten comparisons");
  • ARCHITECTURE (the converter's messages).

@SwayamInSync
SwayamInSync merged commit fe44ed6 into main Oct 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant