Skip to content

[6.1][CAS] Allow empty filename for diagnostics location #78407

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
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
2 changes: 1 addition & 1 deletion lib/Frontend/CachedDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ unsigned DiagnosticSerializer::getFileIDFromBufferID(SourceManager &SM,

auto &Buf = SM.getLLVMSourceMgr().getBufferInfo(Idx);
auto Filename = Buf.Buffer->getBufferIdentifier();
bool IsFileBacked = SM.getFileSystem()->exists(Filename);
bool IsFileBacked = !Filename.empty() && SM.getFileSystem()->exists(Filename);

// Construct and add to files. If there is an IncludeLoc, the file from
// IncludeLoc is added before current file.
Expand Down
68 changes: 68 additions & 0 deletions test/CAS/cached_diagnostics_empty_filename.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// REQUIRES: swift_feature_RegionBasedIsolation
// REQUIRES: objc_interop

// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O -I %t \
// RUN: -disable-implicit-string-processing-module-import \
// RUN: %t/test.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas -module-load-mode prefer-serialized

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
// RUN: %swift_frontend_plain @%t/shim.cmd

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:_SwiftConcurrencyShims > %t/cshim.cmd
// RUN: %swift_frontend_plain @%t/cshim.cmd

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/A.cmd
// RUN: %swift_frontend_plain @%t/A.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CACHE-MISS

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/A.cmd
// RUN: %swift_frontend_plain @%t/A.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CACHE-HIT

// CACHE-MISS: remark: cache miss for input
// CHECK: <module-includes>:1
// CHECK-SAME: note: in file included from <module-includes>:1:
// CHECK: warning: warning a.h
// CACHE-HIT: remark: replay output file

// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
// RUN: echo "\"-disable-implicit-string-processing-module-import\"" >> %t/MyApp.cmd
// RUN: echo "\"-disable-implicit-swift-modules\"" >> %t/MyApp.cmd
// RUN: echo "\"-explicit-swift-module-map-file\"" >> %t/MyApp.cmd
// RUN: echo "\"@%t/map.casid\"" >> %t/MyApp.cmd

// RUN: %target-swift-frontend -cache-compile-job -module-name Test -O -cas-path %t/cas @%t/MyApp.cmd %t/test.swift \
// RUN: -emit-module -o %t/test.swiftmodule -require-explicit-sendable -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation

//--- module.modulemap
module A {
header "a.h"
export *
}

//--- a.h
#warning warning a.h

#pragma clang attribute push(__attribute__((swift_attr("@_nonSendable(_assumed)"))), apply_to = any(objc_interface, record, enum))
@protocol P
@end

@interface C
@end
#pragma clang attribute pop

//--- test.swift
import A
import _Concurrency

func acceptSendable<T: Sendable>(_: T) {
}

func testMe(c: C) {
acceptSendable(c)
}