Skip to content

Commit ab97d50

Browse files
committed
Revert "PrintAsObjC: use header path relative to usr/include when importing non-framework headers"
This reverts commit ebe0a45.
1 parent bbf94fb commit ab97d50

File tree

4 files changed

+2
-47
lines changed

4 files changed

+2
-47
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -332,42 +332,8 @@ static void writeImports(raw_ostream &out,
332332
allPaths.append(module->getTopLevelModuleName());
333333
llvm::sys::path::append(allPaths, Buffer.str());
334334
} else {
335-
auto DirPath = header.Entry->getDir()->getName();
336-
auto I = llvm::sys::path::begin(DirPath),
337-
E = llvm::sys::path::end(DirPath);
338-
llvm::SmallVector<StringRef, 4> Comps;
339-
// Check if the path of the header contains `/usr/include/` in it.
340-
// If so, we print the header include path starting from the next component.
341-
// e.g. for .../usr/include/dispatch/dispatch.h, we print
342-
// #include "dispatch/dispatch.h" because we could assume /usr/include/ is
343-
// in the header search paths.
344-
while (true) {
345-
StringRef Parts[2] = {*I, StringRef()};
346-
++ I;
347-
if (I == E)
348-
break;
349-
Parts[1] = *I;
350-
if (Parts[0] == "usr" && Parts[1] == "include") {
351-
++ I;
352-
for (;I != E; ++ I) {
353-
Comps.push_back(*I);
354-
}
355-
break;
356-
}
357-
};
358-
if (!Comps.empty()) {
359-
// The header is in a deeper location inside /usr/include/, add the
360-
// additional path components before adding the header name.
361-
allPaths.append(Comps.front());
362-
for (auto c: llvm::makeArrayRef(Comps).slice(1)) {
363-
llvm::sys::path::append(allPaths, c);
364-
}
365-
llvm::sys::path::append(allPaths,
366-
llvm::sys::path::filename(header.NameAsWritten));
367-
} else {
368-
// Otherwise, import the header directly.
369-
allPaths.append(header.NameAsWritten);
370-
}
335+
// Otherwise, import the header directly.
336+
allPaths.append(header.NameAsWritten);
371337
}
372338
headerImports.insert(allPaths.str().substr(startIdx));
373339
};

test/Inputs/clang-importer-sdk/usr/include/CTypesCore/module.modulemap

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/Inputs/clang-importer-sdk/usr/include/CTypesCore/values.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/PrintAsObjC/imports.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// CHECK-NEXT: @import Base.ExplicitSub;
1414
// CHECK-NEXT: @import Base.ExplicitSub.ExSub;
1515
// CHECK-NEXT: @import Base.ImplicitSub.ExSub;
16-
// CHECK-NEXT: @import CTypesCore;
1716
// CHECK-NEXT: @import Foundation;
1817
// CHECK-NEXT: @import MostlyPrivate1;
1918
// CHECK-NEXT: @import MostlyPrivate1_Private;
@@ -25,7 +24,6 @@
2524
// CHECK-NEXT: #import <Base.ExplicitSub.h>
2625
// CHECK-NEXT: #import <Base.ExplicitSub.ExSub.h>
2726
// CHECK-NEXT: #import <Base.ImplicitSub.ExSub.h>
28-
// CHECK-NEXT: #import <CTypesCore/values.h>
2927
// CHECK-NEXT: #import <Foundation.h>
3028
// CHECK-NEXT: #import <MostlyPrivate1/MostlyPrivate1.h>
3129
// CHECK-NEXT: #import <MostlyPrivate1_Private/MostlyPrivate1_Private.h>
@@ -40,7 +38,6 @@
4038

4139
// NEGATIVE-NOT: secretMethod
4240

43-
import CTypesCore
4441
import ctypes.bits
4542
import Foundation
4643

@@ -61,7 +58,6 @@ import MostlyPrivate2_Private
6158

6259
@objc class Test {
6360
@objc let word: DWORD = 0
64-
@objc let word_core: DWORD_CORE = 0
6561
@objc let number: TimeInterval = 0.0
6662

6763
@objc let baseI: BaseI = 0

0 commit comments

Comments
 (0)