aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PIC16/PIC16DebugInfo.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-11-14 06:19:49 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-11-14 06:19:49 +0000
commit6fb01a7750e3edd73a7fba957e7f55f5956a760d (patch)
treeb86be483c583b3a4f6ce14b7b0320b992ebce072 /lib/Target/PIC16/PIC16DebugInfo.cpp
parent20162ac5662a45388911ef1d35ba7559aae368f5 (diff)
Fix debug info crashes for PIC16.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88761 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16/PIC16DebugInfo.cpp')
-rw-r--r--lib/Target/PIC16/PIC16DebugInfo.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Target/PIC16/PIC16DebugInfo.cpp b/lib/Target/PIC16/PIC16DebugInfo.cpp
index 0ed44d21fc..49df457af7 100644
--- a/lib/Target/PIC16/PIC16DebugInfo.cpp
+++ b/lib/Target/PIC16/PIC16DebugInfo.cpp
@@ -467,12 +467,18 @@ void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
// Get the file path from CU.
DICompileUnit cu(CU);
- std::string DirName = cu.getDirectory();
- std::string FileName = cu.getFilename();
- std::string FilePath = DirName + "/" + FileName;
+ std::string FilePath = "";
+ if (cu.getDirectory()) {
+ std::string DirName = cu.getDirectory();
+ FilePath = FilePath + DirName + "/";
+ }
+ if (cu.getFilename()) {
+ std::string FileName = cu.getFilename();
+ FilePath = FilePath + FileName;
+ }
- // Nothing to do if source file is still same.
- if ( FilePath == CurFile ) return;
+ // Nothing to do if source file is still same or it is empty.
+ if ( FilePath == CurFile || FilePath == "") return;
// Else, close the current one and start a new.
if (CurFile != "") O << "\n\t.eof";