basic: fix FreeBSD build failure around usage of assert()
#64379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LLVM's
CASReference.h
usesassert()
without first including<cassert>
, which poses a problem here whenCASReference.h
is included first thing in a submodule.In FreeBSD's <assert.h>,
assert()
expands to a call to a function that is declared within header guards. That is, only the first include of<assert.h>
gets the function declaration.This is module-unfriendly, since it means that if multiple submodules of a module both include
<assert.h>
, only one of them ends up with a usableassert()
macro. If you haven't (transitively) included the right submodule, and you haven't included<assert.h>
yourself, then you get a compile error that looks like the following:Ideally
CASReference.h
would include<cassert>
itself. But use ofassert()
without a prior include of<cassert>
is common in LLVM. It's even encouraged by the LLVM "coding standards", which say:Since the include of
CASReference.h
appears to be a temporary workaround, add to it by including<cassert>
, too.