Clang-bugs-at-wip-clang-branch: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
== Clang bugs with known workarounds ==
== Clang bugs with known workarounds ==


* Sometimes diagnostic message have one empty SourceRange, which breaks SourceLocation-based euristic. Example:<br /><code><br />#include &lt;vector&amp;gt;
* Sometimes diagnostic message have one empty SourceRange, which breaks SourceLocation-based euristic. Example:
<code>
#include <vector>


int main()<br />{<br /> std::vector&amp;lt;&gt; a;<br /> return 0;<br />}<br /></code><br />CXPrettyPrinter reports:<br /><code><br />CXDiagnostic: {<br /> 'error: too few template arguments for class template 'vector''<br /> severity: Error<br /> location: {<br /> file: '/home/sergey/Документы/wip-clang/test_projects/objc_test/main.cpp',<br /> line: 5,<br /> column: 10<br /> }<br /> category: 'Semantic Issue';<br /> ranges: [<br /> {<br /> file: '',<br /> from: {0, 0},to: {0, 0}<br /> }<br /> ]<br /> children: [<br /> {<br /> 'note: template is declared here'<br /> severity: Note<br /> location: {<br /> file: '/usr/include/c+''/4.6/bits/stl_vector.h',<br /> line: 180,<br /> column: 11<br /> }<br /> category: 'Semantic Issue';<br /> ranges: [<br /> {<br /> file: '/usr/include/c/4.6/bits/stl_vector.h',<br /> from: {179, 3},to: {179, 65}<br /> }<br /> ]<br /> }<br /> ]<br />}<br /></code>
int main()
<br />h2. Clang bugs
{
<br />Links to reported bugs will be attached in future
std::vector<> a;
<br />* inside lambda, clang doesn't include mutable (non-const) methods of current class even if 'this' was captured by lambda<br />Bug: http://llvm.org/bugs/show_bug.cgi?id=15085<br />See example, completion requested in point marked with '#' sign
return 0;
<br /><code><br />void UnitConsumer::visitChildren()<br />{<br /> visitChildren(cursor, [this](const CXCursor &amp;cursor, const CXCursor &amp; /*parent*/) {<br /> if (cursor.kind == CXCursor_FieldDecl) {<br /> #<br /> }<br /> });<br />}<br /></code>
}
<br />* Clang does not add virtual functions to proposals list<br /><code><br />class Base<br />{<br />public:<br /> virtual void overrideMe(int a);<br />};
</code>
<br />class Derived : public Base<br />{<br />public:<br /> void #<br />};<br /></code>
CXPrettyPrinter reports:
<br />* no way to differ method definition and call with qualifier: completion strings and contexts are the same in both cases: http://llvm.org/bugs/show_bug.cgi?id=15745<br /><code><br />class Foo<br />{<br />public:<br /> void declarable(int a, float b);<br />};
<code>
<br />void Foo::declarable(int a, float b)<br />{<br /> if (a != 1)<br /> Foo::declarable(1, 2.0);<br />}<br /></code>
CXDiagnostic: {
<br />Poor diagnostic for such code if C11 disabled<br /><code><br />enum class EnumScoped<br />{<br />};<br /></code>
'error: too few template arguments for class template 'vector''
<br />* clang does not add classes to completion proposals when completing 'foreach'
severity: Error
<br />* when declaring variable, variable itself proposed with highest priority. It's error.
location: {
<br />* Macro completions not added after class keyword<br /><code><br />class CLANG_EXPORT CodeCompletionResult<br />{<br />};<br /></code>
file: '/home/sergey/Документы/wip-clang/test_projects/objc_test/main.cpp',
<br />* Wrong completions inside function-try-block in constructor: http://llvm.org/bugs/show_bug.cgi?id=15660<br /><code><br />class Class<br />{<br /> int a;<br /> int '''c;<br />public:<br /> Class(int b) try : a(b), c(new int)<br /> {<br /> }<br /> catch (…)<br /> {<br /> // no &quot;delete&amp;quot; proposed<br /> }<br />};<br /></code>
line: 5,
<br />''' Completion with nested names lookup not performed for comparison with enum value<br /><code><br /> if (lexer.tokenKind() == Token::LeftBrace) {<br /> }<br /></code>
column: 10
<br />* Value types completions added where thay shouldn't be<br /><code><br />QStringList createClangOptions(CPlusPlus::ProjectFile::Kind language,<br /> CPlusPlus::ProjectPart::CXXExtensions extensions,<br /> CPlusPlus::ProjectPart::,<br /> CPlusPlus::ProjectPart::QtVersion qtVersion,<br /> const QList&amp;lt;QByteArray&amp;gt; &amp;defines,<br /> const QStringList &amp;includePaths,<br /> const QStringList &amp;frameworkPaths);<br /></code>
}
<br />* C''+11 'override' pseudo-keyword breaks clang_annotateTokens()<br /><code><br />bool init() override;<br /></code>
category: 'Semantic Issue';
ranges: [
{
file: '',
from: {0, 0},to: {0, 0}
}
]
children: [
{
'note: template is declared here'
severity: Note
location: {
file: '/usr/include/c+''/4.6/bits/stl_vector.h',
line: 180,
column: 11
}
category: 'Semantic Issue';
ranges: [
{
file: '/usr/include/c/4.6/bits/stl_vector.h',
from: {179, 3},to: {179, 65}
}
]
}
]
}
</code>


* Poor completion context recognition in template params<br /><code><br />std::vector&amp;lt;#&gt; myVector;<br /></code>
h2. Clang bugs


* Clang doesn't add Informative completion chunk to macro. It better to add macro definition text to informative.<br /><code><br />#define MACRO std::min(left, right)
Links to reported bugs will be attached in future


// Completion proposal &quot;MACRO&amp;quot; doesn't have chunk of kind Informative with text &quot;std::min(left, right)&quot;<br /></code>
* inside lambda, clang doesn't include mutable (non-const) methods of current class even if 'this' was captured by lambda
Bug: http://llvm.org/bugs/show_bug.cgi?id=15085
See example, completion requested in point marked with '#' sign


* Completion stops after asterisk:<br /><code><br />ButtonsFactory '''ButtonsFactory::ms_instance = 0;<br />ButtonsFactory'''// completion requested here<br /></code>
<code>
void UnitConsumer::visitChildren()
{
visitChildren(cursor, [this](const CXCursor &amp;cursor, const CXCursor &amp; /*parent*/) {
if (cursor.kind == CXCursor_FieldDecl) {
#
}
});
}
</code>
 
* Clang does not add virtual functions to proposals list
<code>
class Base
{
public:
virtual void overrideMe(int a);
};
 
class Derived : public Base
{
public:
void #
};
</code>
 
* no way to differ method definition and call with qualifier: completion strings and contexts are the same in both cases: http://llvm.org/bugs/show_bug.cgi?id=15745
<code>
class Foo
{
public:
void declarable(int a, float b);
};
 
void Foo::declarable(int a, float b)
{
if (a != 1)
Foo::declarable(1, 2.0);
}
</code>
 
Poor diagnostic for such code if C11 disabled
<code>
enum class EnumScoped
{
};
</code>
 
* clang does not add classes to completion proposals when completing 'foreach'
 
* when declaring variable, variable itself proposed with highest priority. It's error.
 
* Macro completions not added after class keyword
<code>
class CLANG_EXPORT CodeCompletionResult
{
};
</code>
 
* Wrong completions inside function-try-block in constructor: http://llvm.org/bugs/show_bug.cgi?id=15660
<code>
class Class
{
int a;
int '''c;
public:
Class(int b) try : a(b), c(new int)
{
}
catch (…)
{
// no "delete" proposed
}
};
</code>
 
''' Completion with nested names lookup not performed for comparison with enum value
<code>
if (lexer.tokenKind() == Token::LeftBrace) {
}
</code>
 
* Value types completions added where thay shouldn't be
<code>
QStringList createClangOptions(CPlusPlus::ProjectFile::Kind language,
CPlusPlus::ProjectPart::CXXExtensions extensions,
CPlusPlus::ProjectPart::,
CPlusPlus::ProjectPart::QtVersion qtVersion,
const QList<QByteArray> &amp;defines,
const QStringList &amp;includePaths,
const QStringList &amp;frameworkPaths);
</code>
 
* C''+11 'override' pseudo-keyword breaks clang_annotateTokens()
<code>
bool init() override;
</code>
 
* Poor completion context recognition in template params
<code>
std::vector<#> myVector;
</code>
 
* Clang doesn't add Informative completion chunk to macro. It better to add macro definition text to informative.
<code>
#define MACRO std::min(left, right)
 
// Completion proposal "MACRO" doesn't have chunk of kind Informative with text "std::min(left, right)"
</code>
 
* Completion stops after asterisk:
<code>
ButtonsFactory '''ButtonsFactory::ms_instance = 0;
ButtonsFactory*// completion requested here
</code>


* Macro trick used in GLEW library not handled by completion: http://llvm.org/bugs/show_bug.cgi?id=15631
* Macro trick used in GLEW library not handled by completion: http://llvm.org/bugs/show_bug.cgi?id=15631


* Completion results for function with optional arguments does not have default argument value: http://llvm.org/bugs/show_bug.cgi?id=14477
* Completion results for function with optional arguments does not have default argument value: http://llvm.org/bugs/show_bug.cgi?id=14477

Revision as of 11:03, 25 February 2015


See also

  • ClangCodeModel plugin has class CXPrettyPrinter that prints clang-c types in JSON-like format. Use it to debug and feel free to improve this class.
  • Clang hacking notes

Clang bugs with known workarounds

  • Sometimes diagnostic message have one empty SourceRange, which breaks SourceLocation-based euristic. Example:
#include <vector>

int main()
{
 std::vector<> a;
 return 0;
}

CXPrettyPrinter reports:

CXDiagnostic: {
 'error: too few template arguments for class template 'vector''
 severity: Error
 location: {
 file: '/home/sergey/Документы/wip-clang/test_projects/objc_test/main.cpp',
 line: 5,
 column: 10
 }
 category: 'Semantic Issue';
 ranges: [
 {
 file: '',
 from: {0, 0},to: {0, 0}
 }
 ]
 children: [
 {
 'note: template is declared here'
 severity: Note
 location: {
 file: '/usr/include/c+''/4.6/bits/stl_vector.h',
 line: 180,
 column: 11
 }
 category: 'Semantic Issue';
 ranges: [
 {
 file: '/usr/include/c/4.6/bits/stl_vector.h',
 from: {179, 3},to: {179, 65}
 }
 ]
 }
 ]
}

h2. Clang bugs

Links to reported bugs will be attached in future

  • inside lambda, clang doesn't include mutable (non-const) methods of current class even if 'this' was captured by lambda

Bug: http://llvm.org/bugs/show_bug.cgi?id=15085 See example, completion requested in point marked with '#' sign

void UnitConsumer::visitChildren()
{
 visitChildren(cursor, [this](const CXCursor &amp;cursor, const CXCursor &amp; /*parent*/) {
 if (cursor.kind == CXCursor_FieldDecl) {
 #
 }
 });
}
  • Clang does not add virtual functions to proposals list
class Base
{
public:
 virtual void overrideMe(int a);
};

class Derived : public Base
{
public:
 void #
};
class Foo
{
public:
 void declarable(int a, float b);
};

void Foo::declarable(int a, float b)
{
 if (a != 1)
 Foo::declarable(1, 2.0);
}

Poor diagnostic for such code if C11 disabled

enum class EnumScoped
{
};
  • clang does not add classes to completion proposals when completing 'foreach'
  • when declaring variable, variable itself proposed with highest priority. It's error.
  • Macro completions not added after class keyword
class CLANG_EXPORT CodeCompletionResult
{
};
class Class
{
 int a;
 int '''c;
public:
 Class(int b) try : a(b), c(new int)
 {
 }
 catch ()
 {
 // no "delete" proposed
 }
};

Completion with nested names lookup not performed for comparison with enum value

 if (lexer.tokenKind() == Token::LeftBrace) {
 }
  • Value types completions added where thay shouldn't be
QStringList createClangOptions(CPlusPlus::ProjectFile::Kind language,
 CPlusPlus::ProjectPart::CXXExtensions extensions,
 CPlusPlus::ProjectPart::,
 CPlusPlus::ProjectPart::QtVersion qtVersion,
 const QList<QByteArray> &amp;defines,
 const QStringList &amp;includePaths,
 const QStringList &amp;frameworkPaths);
  • C+11 'override' pseudo-keyword breaks clang_annotateTokens()
bool init() override;
  • Poor completion context recognition in template params
std::vector<#> myVector;
  • Clang doesn't add Informative completion chunk to macro. It better to add macro definition text to informative.
#define MACRO std::min(left, right)

// Completion proposal "MACRO" doesn't have chunk of kind Informative with text "std::min(left, right)"
  • Completion stops after asterisk:
ButtonsFactory '''ButtonsFactory::ms_instance = 0;
ButtonsFactory*// completion requested here