Commit Graph

59 Commits

Author SHA1 Message Date
Allan Shortlidge
f9a93a55d7 NFC: Fix duplicate definition of macro warnings.
Centralize the `SWIFT_{BEGIN/END}_NULLABILITY_ANNOTATIONS` definitions in a new
Nullability.h header to share.
2023-07-27 13:02:22 -07:00
Matt Jacobson
2e629e9fb9 basic: fix FreeBSD build failure around usage of assert()
LLVM's `CASReference.h` uses `assert()` without first including `<cassert>`,
which poses a problem here when `CASReference.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 usable
`assert()` 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:

```
llvm-project/llvm/include/llvm/CAS/CASReference.h:75:5: error: declaration of '__assert' must be imported from module 'LLVM_Utils.Support.MathExtras' before it is required
    assert(InternalRef != getDenseMapEmptyRef() && "Reserved for DenseMapInfo");

/usr/include/assert.h:77:6: note: declaration here is not visible
void __assert(const char *, const char *, int, const char *) __dead2;

swift/include/swift/AST/DeclContext.h:31:10: error: could not build module 'BasicBridging'
#include "swift/Basic/SourceLoc.h"

swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift:13:8: error: could not build C module 'ASTBridging'
import ASTBridging
```

Ideally `CASReference.h` would include `<cassert>` itself.  But use of
`assert()` without a prior include of `<cassert>` is common in LLVM.  It's even
encouraged by the LLVM "coding standards", which say:

> Use the “assert” macro to its fullest. [...] The “<cassert>” header file is
> probably already included by the header files you are using, so it doesn’t
> cost anything to use it.

Since the include of `CASReference.h` appears to be a temporary workaround, add
to it by including `<cassert>`, too.
2023-03-15 06:49:29 -04:00
Erik Eckstein
87bb0cfd3c Workaround to avoid a compiler error because cas::ObjectRef is not defined when including VirtualFileSystem.h 2022-11-04 20:44:19 +01:00
Egor Zhdan
0e2d438c5b [cxx-interop][SwiftCompilerSources] Use llvm::StringRef instead of BridgedStringRef
rdar://83361000
2022-07-21 16:32:16 +01:00
Egor Zhdan
220d95e3d9 [cxx-interop][SwiftCompilerSources] Use swift::CharSourceRange instead of BridgedCharSourceRange
This removes some of the bridging code and replaces it with C++ calls.

rdar://83361087
2022-07-07 12:00:12 +01:00
Egor Zhdan
038a4f0b80 [cxx-interop][SwiftCompilerSources] Use swift::SourceLoc instead of BridgedSourceLoc
C++ interop is now enabled in SwiftCompilerSources, so we can remove some of the C bridging layer and use C++ classes directly from Swift.

rdar://83361087
2022-06-11 00:13:39 +01:00
Rintaro Ishizaki
4d9b65d961 [SwiftCompiler] Add DiagnosticEngine bridging
* 'SourceLoc' and 'CharSourceRange' bridging in Basic
* New 'AST' bridging. 'DiagID', 'DiagnosticArgument', 'DiagnosticFixIt',
  and 'DiagnosticEngine'
2022-02-23 15:57:33 -08:00
Rintaro Ishizaki
da6814d510 [SwiftCompiler] Make BridgedArrayRef.data nullable
ArrayRef.data() can be nullptr when the array is empty.
2022-02-20 22:30:18 -08:00
Rintaro Ishizaki
7486cd1c21 [SwiftCompiler] Move common bridging facilities to 'Basic'
A preparation for AST/DiagnosticEngine bridging
2022-02-20 22:06:39 -08:00