Example #1
0
 internal Diagnostic(IntPtr native) {
     Level = Interop.clang_getDiagnosticSeverity(native);
     Location = new SourceLocation(Interop.clang_getDiagnosticLocation(native));
     Spelling = Interop.clang_getDiagnosticSpelling(native).ManagedString;
     Ranges = Util.Range(0u, Interop.clang_getDiagnosticNumRanges(native)).Select(i =>
         new SourceRange(Interop.clang_getDiagnosticRange(native, i))).ToArray();
     uint numFixits = Interop.clang_getDiagnosticNumFixIts(native);
     Fixits = Util.Range(0u, Interop.clang_getDiagnosticNumFixIts(native)).Select(i => {
         Interop.SourceRange range;
         string spelling = Interop.clang_getDiagnosticFixIt(native, i, out range).ManagedString;
         return new FixIt { Fix = spelling, Range = new SourceRange(range) };
     }).ToArray();
     Description = Interop.clang_formatDiagnostic(native, DefaultDisplayOptions).ManagedString;
     Interop.clang_disposeDiagnostic(native);
 }
Example #2
0
 /// <summary>
 /// Visit the set of preprocessor inclusions in a translation unit. The visitor
 /// function is called with the provided data for every included file. This does
 /// not include headers included by the PCH file (unless one is inspecting the
 /// inclusions in the PCH file itself).
 /// </summary>
 /// <param name="visitor">The visiting delegate.</param>
 public void VisitInclusions(InclusionVisitor visitor) {
     Interop.InclusionVisitor nativeVisitor = (file, stack, size, data) => {
         var inclusionStack = new SourceLocation[(int)size];
         unsafe {
             var srcPtr = (Interop.SourceLocation*)stack;
             for (uint i = 0; i < size; ++i) {
                 inclusionStack[i] = (new SourceLocation(*(srcPtr + i)));
             }
         }
         visitor(new File(file), inclusionStack);
     };
     Interop.clang_getInclusions(Native, nativeVisitor, IntPtr.Zero);
 }
Example #3
0
 /// <summary>
 /// Map a source location to the cursor that describes the entity at that location in the source code.
 /// GetCursor() maps an arbitrary source location within a translation unit down to the most specific
 /// cursor that describes the entity at that location. For example, given an expression x + y, invoking
 /// GetCursor() with a source location pointing to "x" will return the cursor for "x"; similarly for "y".
 /// If the cursor points anywhere between "x" or "y" (e.g., on the + or the whitespace around it),
 /// GetCursor() will return a cursor referring to the "+" expression.
 /// </summary>
 /// <param name="location">The location to find a cursor at.</param>
 /// <returns></returns>
 public Cursor GetCursor(SourceLocation location) {
     return new Cursor(Interop.clang_getCursor(Native, location.Native));
 }
Example #4
0
 public bool Equals(SourceLocation other) {
     return data0 == other.data0 && data1 == other.data1 && data2 == other.data2;
 }
Example #5
0
 public static extern Cursor clang_getCursor(IntPtr tu, SourceLocation loc);
Example #6
0
 public unsafe static extern void clang_getInstantiationLocation(
     SourceLocation location, IntPtr* file, out uint line, out uint column, out uint offset);
Example #7
0
 public static extern SourceRange clang_getRange(SourceLocation begin, SourceLocation end);
Example #8
0
 public static extern uint clang_equalLocations(SourceLocation loc1, SourceLocation loc2);
Example #9
0
 public bool Equals(SourceLocation other) {
     return this == other;
 }
Example #10
0
 /// <summary>
 /// Map a source location to the cursor that describes the entity at that location in the source code.
 /// GetCursor() maps an arbitrary source location within a translation unit down to the most specific
 /// cursor that describes the entity at that location. For example, given an expression x + y, invoking
 /// GetCursor() with a source location pointing to "x" will return the cursor for "x"; similarly for "y".
 /// If the cursor points anywhere between "x" or "y" (e.g., on the + or the whitespace around it),
 /// GetCursor() will return a cursor referring to the "+" expression.
 /// </summary>
 /// <param name="location">The location to find a cursor at.</param>
 /// <returns></returns>
 public Cursor GetCursor(SourceLocation location)
 {
     return(new Cursor(Interop.clang_getCursor(Native, location.Native)));
 }