Jump to content

Clang-bugs-at-wip-clang-branch

From Qt Wiki
Revision as of 10:43, 24 February 2015 by Maintenance script (talk | contribs)


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:
    <br />#include &lt;vector&amp;gt;
    
    int main()<br />{<br /> std::vector&amp;lt;&gt; a;<br /> return 0;<br />}<br />
    

    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 &cursor, const CXCursor & /*parent*/) {
if (cursor.kind == CXCursor_FieldDecl) {
#
}
});
}


* Clang does not add virtual functions to proposals list

<br />class Base<br />{<br />public:<br /> virtual void overrideMe(int a);<br />};
<br />class Derived : public Base<br />{<br />public:<br /> void #<br />};<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 />class Foo<br />{<br />public:<br /> void declarable(int a, float b);<br />};
<br />void Foo::declarable(int a, float b)<br />{<br /> if (a != 1)<br /> Foo::declarable(1, 2.0);<br />}<br />


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
{
};

* Wrong completions inside function-try-block in constructor: http://llvm.org/bugs/show_bug.cgi?id=15660

class Class
{
int a;
int c;
public:
Class(int b) try : a(b), c(new int)
{
}
catch (…)
{
// no "delete&quot; 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&lt;QByteArray&gt; &defines,
const QStringList &includePaths,
const QStringList &frameworkPaths);

* C+11 'override' pseudo-keyword breaks clang_annotateTokens()

bool init() override;

  • Poor completion context recognition in template params

    std::vector&lt;#> myVector;
  • Clang doesn't add Informative completion chunk to macro. It better to add macro definition text to informative.
    <br />#define MACRO std::min(left, right)
    
    // Completion proposal &quot;MACRO&amp;quot; doesn't have chunk of kind Informative with text &quot;std::min(left, right)&quot;<br />
    
  • Completion stops after asterisk:

    ButtonsFactory ButtonsFactory::ms_instance = 0;
    ButtonsFactory
    // completion requested here