Don't try to call getFileCharacteristic if the function declaration has an invalid source location (as is the case for the global allocation functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72671 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index c09a13a..6ee1223 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -93,8 +93,9 @@
!Context.getLangOptions().CPlusPlus ||
// "main" is not mangled in C++
FD->isMain() ||
- // No mangling in an "implicit extern C" header.
- Context.getSourceManager().getFileCharacteristic(FD->getLocation())
+ // No mangling in an "implicit extern C" header.
+ (FD->getLocation().isValid() &&
+ Context.getSourceManager().getFileCharacteristic(FD->getLocation()))
== SrcMgr::C_ExternCSystem ||
// No name mangling in a C linkage specification.
isInCLinkageSpecification(FD))