Revert "PrintAsObjC: use header path relative to usr/include when importing non-framework headers"

This reverts commit ebe0a45583.
This commit is contained in:
Doug Gregor
2020-03-27 21:00:51 -07:00
parent bbf94fbec8
commit ab97d50b0f
4 changed files with 2 additions and 47 deletions

View File

@@ -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));
};

View File

@@ -1,4 +0,0 @@
module CTypesCore [system] [extern_c] {
umbrella header "values.h"
export *
}

View File

@@ -1,3 +0,0 @@
typedef int DWORD_CORE;
#define MY_INT 123

View File

@@ -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