File tree Expand file tree Collapse file tree 4 files changed +41
-4
lines changed Expand file tree Collapse file tree 4 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -241,11 +241,15 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
241241 return L;
242242
243243 if (auto *ClangDecl = D->getClangDecl ()) {
244- auto ClangSrcLoc = ClangDecl->getBeginLoc ();
244+ clang::SourceLocation ClangSrcLoc = ClangDecl->getBeginLoc ();
245245 clang::SourceManager &ClangSM =
246246 CI.getClangASTContext ().getSourceManager ();
247- L.Line = ClangSM.getPresumedLineNumber (ClangSrcLoc);
248- L.Filename = ClangSM.getBufferName (ClangSrcLoc);
247+ clang::PresumedLoc PresumedLoc = ClangSM.getPresumedLoc (ClangSrcLoc);
248+ if (!PresumedLoc.isValid ())
249+ return L;
250+ L.Line = PresumedLoc.getLine ();
251+ L.Column = PresumedLoc.getColumn ();
252+ L.Filename = PresumedLoc.getFilename ();
249253 return L;
250254 }
251255 return getSwiftDebugLoc (DI, D, End);
Original file line number Diff line number Diff line change 1+ #define MY_ENUM (NAME ) \
2+ enum NAME : int NAME; \
3+ enum NAME : int
4+
5+ MY_ENUM (macro_enum ) {
6+ zero = 0
7+ };
Original file line number Diff line number Diff line change @@ -14,4 +14,9 @@ module OtherClangModule {
1414 header "OtherSubModule.h"
1515 export *
1616 }
17- }
17+ }
18+
19+ module Macro {
20+ header "Macro.h"
21+ }
22+
Original file line number Diff line number Diff line change 1+ // REQUIRES: objc-interop
2+ // RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - \
3+ // RUN: -parse-as-library | %FileCheck %s
4+
5+ // The source file for "macro_enum", which is defined using a macro, should be
6+ // correctly identified.
7+
8+ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "macro_enum",
9+ // CHECK-SAME: file: ![[MACRO_H:[0-9]+]]
10+ // CHECK: ![[MACRO_H]] = !DIFile(filename: "{{.*}}/Inputs/Macro.h",
11+
12+ import Macro
13+
14+ public func f( _ e : macro_enum ) -> Int32 {
15+ switch ( e) {
16+ case zero:
17+ return 0
18+ default :
19+ return e. rawValue
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments