Ejemplo n.º 1
0
        private bool DealingWithDiagnostic(CXDiagnostic d)
        {
            // error spelling
            string spelling = clang.getDiagnosticSpelling(d).ToString();

            // category text
            string categoryText = clang.getDiagnosticCategoryText(d).ToString();

            // severity text
            CXDiagnosticSeverity severity = clang.getDiagnosticSeverity(d);
            string severityStr            = ClangTraits.ToString(severity);

            // source location
            CXSourceLocation location = clang.getDiagnosticLocation(d);
            CXFile           file     = new CXFile(IntPtr.Zero);

            clang.getInstantiationLocation(
                location,
                out file,
                out uint line,
                out uint column,
                out uint offset);

            string fileName = clang.getFileName(file).ToString();

            clang.disposeDiagnostic(d);

            string errorString = string.Format("{0}: {1}-{2}, IN {3}, line: {4}, column: {5}",
                                               severityStr, spelling, categoryText, fileName, line, column);

            return(ClangTraits.IsFatal(severity));
        }
Ejemplo n.º 2
0
        public static string ToString(CXDiagnosticSeverity severity)
        {
            switch (severity)
            {
            case CXDiagnosticSeverity.CXDiagnostic_Error:
                return("Error");

            case CXDiagnosticSeverity.CXDiagnostic_Fatal:
                return("Fatal");

            case CXDiagnosticSeverity.CXDiagnostic_Ignored:
                return("Ignore");

            case CXDiagnosticSeverity.CXDiagnostic_Note:
                return("Note");

            case CXDiagnosticSeverity.CXDiagnostic_Warning:
                return("Warning");

            default:
                return("Unknown");
            }
        }
Ejemplo n.º 3
0
 public static bool IsFatal(CXDiagnosticSeverity severity)
 {
     return(CXDiagnosticSeverity.CXDiagnostic_Fatal == severity ||
            CXDiagnosticSeverity.CXDiagnostic_Error == severity);
 }