Debug Info: Create artificial functions in a virtual file <compiler-generated>.

For the majority of artificial helper functions the filename is
actively misleading since it usually represents the file of the caller
that triggered the helper to be generated. Instead, this patch creates
a virtual filname `<compiler-generated>` to make it very obvious that
the function has not correspondence to any source code.

<rdar://problem/33809560>
This commit is contained in:
Adrian Prantl
2018-01-12 10:29:58 -08:00
parent c74ae5f375
commit b4781f63ef
5 changed files with 42 additions and 29 deletions

View File

@@ -432,6 +432,12 @@ public:
return isDebugInfoLoc() ? Loc.DebugInfoLoc
: decode(getDebugSourceLoc(), SM);
}
/// Compiler-generated locations may be applied to instructions without any
/// clear correspondence to an AST node in an otherwise normal function.
static DebugLoc getCompilerGeneratedDebugLoc() {
return {0, 0, "<compiler-generated>"};
}
/// Pretty-print the value.
void dump(const SourceManager &SM) const;
@@ -487,8 +493,11 @@ public:
/// specified type is incorrect, asserts.
template <typename T> T *castTo() const { return castNodeTo<T>(Loc.ASTNode); }
/// Compiler-generated locations may be applied to instructions without any
/// clear correspondence to an AST node in an otherwise normal function.
/// The auto-generated bit also turns off certain diagnostics passes such.
static RegularLocation getAutoGeneratedLocation() {
RegularLocation AL;
RegularLocation AL(getCompilerGeneratedDebugLoc());
AL.markAutoGenerated();
return AL;
}
@@ -502,12 +511,6 @@ private:
}
};
/// Compiler-generated locations may be applied to instructions without any
/// clear correspondence to an AST node.
static inline RegularLocation getCompilerGeneratedLocation() {
return {SourceLoc()};
}
/// Used to represent a return instruction in user code.
///
/// Allowed on an BranchInst, ReturnInst.
@@ -712,7 +715,8 @@ class SILDebugLocation {
public:
SILDebugLocation()
: Scope(nullptr), Location(getCompilerGeneratedLocation()) {}
: Scope(nullptr),
Location(RegularLocation::getAutoGeneratedLocation()) {}
SILDebugLocation(SILLocation Loc, const SILDebugScope *DS)
: Scope(DS), Location(Loc) {}
SILLocation getLocation() const { return Location; }