[cfe-commits] r144793 - /cfe/trunk/tools/libclang/CIndexDiagnostic.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Nov 16 00:59:00 PST 2011


Author: akirtzidis
Date: Wed Nov 16 02:59:00 2011
New Revision: 144793

URL: http://llvm.org/viewvc/llvm-project?rev=144793&view=rev
Log:
[libclang] Add a comment in lazyCreateDiags to explain why the check and reset of
diagnostic set is necessary.

Modified:
    cfe/trunk/tools/libclang/CIndexDiagnostic.cpp

Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.cpp?rev=144793&r1=144792&r2=144793&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.cpp Wed Nov 16 02:59:00 2011
@@ -44,6 +44,23 @@
   ASTUnit *AU = static_cast<ASTUnit *>(TU->TUData);
 
   if (TU->Diagnostics && checkIfChanged) {
+    // In normal use, ASTUnit's diagnostics should not change unless we reparse.
+    // Currently they can only change by using the internal testing flag
+    // '-error-on-deserialized-decl' which will error during deserialization of
+    // a declaration. What will happen is:
+    //
+    //  -c-index-test gets a CXTranslationUnit
+    //  -checks the diagnostics, the diagnostics set is lazily created,
+    //     no errors are reported
+    //  -later does an operation, like annotation of tokens, that triggers
+    //     -error-on-deserialized-decl, that will emit a diagnostic error,
+    //     that ASTUnit will catch and add to its stored diagnostics vector.
+    //  -c-index-test wants to check whether an error occurred after performing
+    //     the operation but can only query the lazily created set.
+    //
+    // We check here if a new diagnostic was appended since the last time the
+    // diagnostic set was created, in which case we reset it.
+
     CXDiagnosticSetImpl *
       Set = static_cast<CXDiagnosticSetImpl*>(TU->Diagnostics);
     if (AU->stored_diag_size() != Set->getNumDiagnostics()) {





More information about the cfe-commits mailing list