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

List:       cfe-dev
Subject:    [cfe-dev] canonical type for C++11 auto
From:       Milian Wolff <mail () milianw ! de>
Date:       2015-07-26 13:31:14
Message-ID: 23968913.ujE5OEiYNs () agathebauer
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Hey all,

I want to scratch my own itch by fixing the issue that clang_getCanonicalType 
does not deduce the type for variables such as `auto i = 1;`. See for context:

https://llvm.org/bugs/show_bug.cgi?id=18669
http://clang-developers.42468.n3.nabble.com/API-for-auto-type-deduction-in-libclang-td4037350.html

I added a simple unit test as the first step:

    $ cat test/Index/cxx11-print-type.cpp
    auto a = 1;

    // RUN: c-index-test -test-print-type -std=c++11 %s | FileCheck %s
    // CHECK: VarDecl=a:1:6 [type=auto] [typeKind=Unexposed]
    [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]

Running the first half manually I get:

    VarDecl=a:1:6 (Definition) [type=auto] [typekind=Unexposed] [isPOD=0]

Sadly, I'm a bit lost as to where I'd have to fix this. Looking at 
CXType.cpp's clang_getCanonicalType implementation, I tried something like 
this:

    fprintf(stderr, "--------------> undeduced?: %d\n", T->isUndeducedType());
    if (T->isUndeducedType()) {
      auto d = T->getContainedAutoType()->getDeducedType();
      fprintf(stderr, "--------------> deduced valid? %d\n", !d.isNull());
      if (!d.isNull()) {
        T = d;
      }
    }
 
This shows me that for the above input (i.e. `auto i = 1;`), the type is 
undeduced, but I also cannot force deduction by getDeducedType (probably me 
abusing/misinterpreting the API). So what can be done here - how could it be 
fixed? Where would it be fixed?

Thanks

-- 
Milian Wolff
mail@milianw.de
http://milianw.de
["signature.asc" (application/pgp-signature)]

_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


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

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