Commits

Ivan Vučica committed 9ab3b3e

Fixed an exception occurring with some errors that don't return a location.

  • Participants
  • Parent commits 2e327fd

Comments (0)

Files changed (1)

Editor Teksta/IVSourceCodeDocument.m

         CXDiagnostic d = clang_getDiagnostic(self.codeCompletionTranslationUnit, i);
         CXString diagnosticDescriptionCLSTR = clang_formatDiagnostic(d,
                                                                      clang_defaultDiagnosticDisplayOptions());
-        NSString * diagnosticDescription = [NSString stringWithUTF8String:clang_getCString(diagnosticDescriptionCLSTR)];
+        NSString * diagnosticDescription = [NSString stringWithUTF8String:clang_getCString(diagnosticDescriptionCLSTR) ?: "<none>"];
         //
         CXString diagnosticSpellingCLSTR = clang_getDiagnosticSpelling(d);
-        NSString * diagnosticSpelling = [NSString stringWithUTF8String:clang_getCString(diagnosticSpellingCLSTR)];
+        NSString * diagnosticSpelling = [NSString stringWithUTF8String:clang_getCString(diagnosticSpellingCLSTR) ?: "<none>"];
         //
         CXString diagnosticCategoryNameCLSTR = clang_getDiagnosticCategoryName(clang_getDiagnosticCategory(d));
-        NSString * diagnosticCategoryName = [NSString stringWithUTF8String:clang_getCString(diagnosticCategoryNameCLSTR)];
+        NSString * diagnosticCategoryName = [NSString stringWithUTF8String:clang_getCString(diagnosticCategoryNameCLSTR) ?: "<none>"];
         //
         NSString * diagnosticSeverity;
         switch(clang_getDiagnosticSeverity(d))
         CXFile diagnosticFile;
         clang_getSpellingLocation(diagnosticLocation, &diagnosticFile, &diagnosticLocationLine, &diagnosticLocationColumn, &diagnosticLocationOffset);
         CXString diagnosticFileNameCLSTR = clang_getFileName(diagnosticFile);
-        NSString * diagnosticLocationDescription = [NSString stringWithFormat:@"[%d:%d] %@", diagnosticLocationLine, diagnosticLocationColumn, [[NSString stringWithUTF8String:clang_getCString(diagnosticFileNameCLSTR)] lastPathComponent]];
+        NSString * diagnosticLocationDescription = [NSString stringWithFormat:@"[%d:%d] %@", diagnosticLocationLine, diagnosticLocationColumn, [[NSString stringWithUTF8String:clang_getCString(diagnosticFileNameCLSTR) ?: "none"] lastPathComponent]];
         
         NSDictionary * diagnostic = [NSDictionary dictionaryWithObjectsAndKeys:
                                      diagnosticCategoryName, @"diagnosticCategoryName",