mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Revert "PrintAsObjC: use header path relative to usr/include when importing non-framework headers"
This reverts commit ebe0a45583.
This commit is contained in:
@@ -332,42 +332,8 @@ static void writeImports(raw_ostream &out,
|
||||
allPaths.append(module->getTopLevelModuleName());
|
||||
llvm::sys::path::append(allPaths, Buffer.str());
|
||||
} else {
|
||||
auto DirPath = header.Entry->getDir()->getName();
|
||||
auto I = llvm::sys::path::begin(DirPath),
|
||||
E = llvm::sys::path::end(DirPath);
|
||||
llvm::SmallVector<StringRef, 4> Comps;
|
||||
// Check if the path of the header contains `/usr/include/` in it.
|
||||
// If so, we print the header include path starting from the next component.
|
||||
// e.g. for .../usr/include/dispatch/dispatch.h, we print
|
||||
// #include "dispatch/dispatch.h" because we could assume /usr/include/ is
|
||||
// in the header search paths.
|
||||
while (true) {
|
||||
StringRef Parts[2] = {*I, StringRef()};
|
||||
++ I;
|
||||
if (I == E)
|
||||
break;
|
||||
Parts[1] = *I;
|
||||
if (Parts[0] == "usr" && Parts[1] == "include") {
|
||||
++ I;
|
||||
for (;I != E; ++ I) {
|
||||
Comps.push_back(*I);
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
if (!Comps.empty()) {
|
||||
// The header is in a deeper location inside /usr/include/, add the
|
||||
// additional path components before adding the header name.
|
||||
allPaths.append(Comps.front());
|
||||
for (auto c: llvm::makeArrayRef(Comps).slice(1)) {
|
||||
llvm::sys::path::append(allPaths, c);
|
||||
}
|
||||
llvm::sys::path::append(allPaths,
|
||||
llvm::sys::path::filename(header.NameAsWritten));
|
||||
} else {
|
||||
// Otherwise, import the header directly.
|
||||
allPaths.append(header.NameAsWritten);
|
||||
}
|
||||
// Otherwise, import the header directly.
|
||||
allPaths.append(header.NameAsWritten);
|
||||
}
|
||||
headerImports.insert(allPaths.str().substr(startIdx));
|
||||
};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
module CTypesCore [system] [extern_c] {
|
||||
umbrella header "values.h"
|
||||
export *
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
typedef int DWORD_CORE;
|
||||
|
||||
#define MY_INT 123
|
||||
@@ -13,7 +13,6 @@
|
||||
// CHECK-NEXT: @import Base.ExplicitSub;
|
||||
// CHECK-NEXT: @import Base.ExplicitSub.ExSub;
|
||||
// CHECK-NEXT: @import Base.ImplicitSub.ExSub;
|
||||
// CHECK-NEXT: @import CTypesCore;
|
||||
// CHECK-NEXT: @import Foundation;
|
||||
// CHECK-NEXT: @import MostlyPrivate1;
|
||||
// CHECK-NEXT: @import MostlyPrivate1_Private;
|
||||
@@ -25,7 +24,6 @@
|
||||
// CHECK-NEXT: #import <Base.ExplicitSub.h>
|
||||
// CHECK-NEXT: #import <Base.ExplicitSub.ExSub.h>
|
||||
// CHECK-NEXT: #import <Base.ImplicitSub.ExSub.h>
|
||||
// CHECK-NEXT: #import <CTypesCore/values.h>
|
||||
// CHECK-NEXT: #import <Foundation.h>
|
||||
// CHECK-NEXT: #import <MostlyPrivate1/MostlyPrivate1.h>
|
||||
// CHECK-NEXT: #import <MostlyPrivate1_Private/MostlyPrivate1_Private.h>
|
||||
@@ -40,7 +38,6 @@
|
||||
|
||||
// NEGATIVE-NOT: secretMethod
|
||||
|
||||
import CTypesCore
|
||||
import ctypes.bits
|
||||
import Foundation
|
||||
|
||||
@@ -61,7 +58,6 @@ import MostlyPrivate2_Private
|
||||
|
||||
@objc class Test {
|
||||
@objc let word: DWORD = 0
|
||||
@objc let word_core: DWORD_CORE = 0
|
||||
@objc let number: TimeInterval = 0.0
|
||||
|
||||
@objc let baseI: BaseI = 0
|
||||
|
||||
Reference in New Issue
Block a user