[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevelop/5.0] languages/clang/duchain: Show typename to the user even if duchain decl. wasn't found
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2016-01-31 21:21:01
Message-ID: E1aPzQb-0000dB-SH () scm ! kde ! org
[Download RAW message or body]

Git commit 13ec6e36f110e14e8618c0e4ca06e043a7689924 by David Nolden.
Committed on 31/01/2016 at 21:20.
Pushed by zwabel into branch '5.0'.

Show typename to the user even if duchain decl. wasn't found

Ideally we would always find a duchain declaration, but on
my very complex project with lots of preprocessor and
#include magic this often fails. The reason why it fails
is subject for future research. But in any case, we should
always show what we know to the user. Before this, many
objects were just annotated with the typename "<class>";
now it'll show the plain typename, similar to DelayedType.

M  +12   -2    languages/clang/duchain/builder.cpp

http://commits.kde.org/kdevelop/13ec6e36f110e14e8618c0e4ca06e043a7689924

diff --git a/languages/clang/duchain/builder.cpp \
b/languages/clang/duchain/builder.cpp index 6f8792d..22d00f0 100644
--- a/languages/clang/duchain/builder.cpp
+++ b/languages/clang/duchain/builder.cpp
@@ -514,7 +514,11 @@ struct Visitor
         }
 
         auto t = new StructureType;
-        t->setDeclaration(decl.data());
+        if (decl) {
+            t->setDeclaration(decl.data());
+        } else {    // fallback, at least give the spelling to the user
+            t->setDeclarationId(DeclarationId(IndexedQualifiedIdentifier(QualifiedIdentifier(ClangString(clang_getTypeSpelling(type)).toString()))));
 +        }
         return t;
     }
 
@@ -680,7 +684,13 @@ struct Visitor
         auto decl = declaration ? declaration : findDeclaration(typeDecl);
 
         DUChainReadLocker lock;
-        cst->setDeclaration(decl.data());
+        if (decl) {
+            cst->setDeclaration(decl.data());
+        } else { // fallback, at least give the spelling to the user
+            Identifier id(tStr);
+            id.clearTemplateIdentifiers();
+            cst->setDeclarationId(DeclarationId(IndexedQualifiedIdentifier(QualifiedIdentifier(id))));
 +        }
 
         return cst;
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic