vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Defined __clang__ under Linux, but enable_if attribute parse error

Open fcharlie opened this issue 5 years ago • 31 comments

Type: LanguageService

Describe the bug

  • OS and Version:
#lsb_release
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
# uname -a
Linux **** 4.18.0-20-generic #21~18.04.1-Ubuntu SMP Wed May 8 08:43:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • VS Code Version:
# code --version
1.34.0
a622c65b2c713c890fcf4fbf07cf34049d5fe758
x64
  • C/C++ Extension Version: Version 0.23.1: May 13, 2019
{
    "C_Cpp.clang_format_style": "LLVM",
    "C_Cpp.intelliSenseEngine": "Default",
    "C_Cpp.workspaceSymbols": "Just My Code",
    "C_Cpp.clang_format_sortIncludes": false,
    "C_Cpp.clang_format_fallbackStyle": "LLVM",
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.updateChannel": "Insiders",
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.default.intelliSenseMode": "clang-x64"
}
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

When I used absl::FPrintF, VSCode cpptools reported some errors in the code that could be compiled. As shown in the screenshot below.

Abesil uses a feature of Clang, the enable_if attribute, to derive whether the format type matches at compile time. But I found that VSCode cpptools, although clang is defined, and __has_attribute(enable_if) is true, it doesn't seem to be a good derivation of whether the type matches, only constant reports:

'enable_if' attributes with conditions that are not constant values are not currently supported -- attribute was declared here

And enable_if click Go Definition to to jump to std::enable_if

Clang: The enable_if attribute

Screenshots

2019-05-24 14-51-23屏幕截图

Additional context

fcharlie avatar May 24 '19 07:05 fcharlie

Our next release has an updated parser which may have fixed this already, but I can't tell because I don't have an isolated repro. If you could provide an isolated repro sample code I could check or file a bug with the parser team.

sean-mcmanus avatar May 25 '19 02:05 sean-mcmanus

I got the repro using the linked GitHub project.

UPDATE: The bug still repros in our pending Insider release.

sean-mcmanus avatar May 25 '19 02:05 sean-mcmanus

@sean-mcmanus OK. You can use my absl fork and example: https://github.com/fcharlie/abslexample

fcharlie avatar May 25 '19 02:05 fcharlie

Any updates on when this will be fixed? The issue is still present in the latest version :/

theunwisewolf avatar Dec 12 '19 08:12 theunwisewolf

I'm not able to repro the issue now. Can someone run a C/C++: Log Diagnostics and provide more info on what version of clang is being used?

I'm using

    Compiler Path: /usr/bin/clang
    Includes:
        /usr/include/c++/7
        /usr/include/x86_64-linux-gnu/c++/7
        /usr/include/c++/7/backward
        /usr/lib/llvm-6.0/lib/clang/6.0.0/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
        /mnt/c/Users/user/Downloads/abseil-cpp-master/abseil-cpp-master
        /mnt/c/Users/user/Downloads/abseil-cpp-master/abseil-cpp-master/absl/base
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
        ABSL_INTERNAL_ENABLE_FORMAT_CHECKER=0
    Standard Version: c++17
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=60000

sean-mcmanus avatar Dec 14 '19 00:12 sean-mcmanus

I can confirm that this problem persists.

clang version 9.0.1 (clangbuilder.io f8f1e81363003f79e137134fdb1142e58ab88fb7)
Target: x86_64-fbi-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm-9/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64

-------- Diagnostics - 2019/12/16 上午9:54:12
Version: 0.26.2
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "compilerPath": "/opt/llvm-9/bin/clang",
    "knownCompilers": [
        {
            "path": "/opt/llvm-9/bin/clang",
            "isC": true
        },
        {
            "path": "/opt/llvm-9/bin/clang++",
            "isC": false
        },
        {
            "path": "/usr/bin/gcc",
            "isC": true
        },
        {
            "path": "/usr/bin/g++",
            "isC": false
        },
        {
            "path": "/usr/bin/cpp",
            "isC": false
        },
        {
            "path": "/usr/bin/gcc-8",
            "isC": true
        },
        {
            "path": "/usr/bin/g++-8",
            "isC": false
        },
        {
            "path": "/usr/bin/gcc-7",
            "isC": true
        },
        {
            "path": "/usr/bin/g++-7",
            "isC": false
        },
        {
            "path": "/opt/llvm-9/bin/clang",
            "isC": false
        }
    ],
    "compilerArgs": [],
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "clang-x64",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ ~/development/vcs/git-hook/tools/hkconfig/main.cc ]:
   ~/development/vcs/git-hook/include/extra/cpptoml.h
    ~/development/vcs/git-hook/build/_deps/absl-src/absl/strings/str_format.h
Translation Unit Configurations:
[ ~/development/vcs/git-hook/tools/hkconfig/main.cc ]:
    Process ID: 1621
    Memory Usage: 323 MB
    Compiler Path: /opt/llvm-9/bin/clang
    Includes:
        /usr/include/c++/9
        /usr/include/x86_64-linux-gnu/c++/9
        /usr/include/c++/9/backward
        /usr/local/include
        /opt/llvm-9/lib/clang/9.0.1/include
        /usr/include/x86_64-linux-gnu
        /usr/include
        ~/development/vcs/git-hook/include
        ~/development/vcs/git-hook/build/include
        ~/development/vcs/git-hook/build/_deps/absl-src
        ~/development/vcs/git-hook/build/_deps/absl-src/absl/base
       ~/development/vcs/git-hook/include/extra
    Standard Version: c++17
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=90001
Total Memory Usage: 323 MB

2019-12-16 09-50-51屏幕截图 2019-12-16 09-52-00屏幕截图

fcharlie avatar Dec 16 '19 01:12 fcharlie

Okay, I repro it now on Linux (and in VS, not sure why WSL didn't repro it) -- I'm looking into filing a VS bug...I'm not sure why I didn't file a VS bug originally.

sean-mcmanus avatar Dec 16 '19 23:12 sean-mcmanus

I've filed a bug on VS at https://developercommunity.visualstudio.com/content/problem/858569/incorrect-cc-intellisense-error-enable-if-attribut.html .

Sorry about not following up on this issue earlier -- the issue appears to have "gotten lost".

sean-mcmanus avatar Dec 17 '19 01:12 sean-mcmanus

@sean-mcmanus Not a problem! Thanks for the quick replies.

theunwisewolf avatar Dec 18 '19 11:12 theunwisewolf

@sean-mcmanus I am eager to know if there is any recent progress on this issue. PS: I am using Remote-WSL to develop C ++ projects. If I am running Ubuntu, I can also use Atom (Linter-Clang) as an alternative.

I took a look at the commits for this project and it seems that there haven't been any recent commits to the 'intellisense' issue.

fcharlie avatar Feb 21 '20 02:02 fcharlie

@fcharlie The bug is being tracked by https://developercommunity.visualstudio.com/content/problem/858569/incorrect-cc-intellisense-error-enable-if-attribut.html -- it could use more upvotes. It would need to get fixed in our closed source code shared with VS so you wouldn't see any IntelliSense parsing fixed in our open source commits.

sean-mcmanus avatar Feb 21 '20 20:02 sean-mcmanus

@sean-mcmanus Because IntelliSense is closed source software, we can't get the latest progress, so I want to let you know the progress of the repair. Thanks.

fcharlie avatar Feb 24 '20 09:02 fcharlie

The "upstream" issue that was created was closed for "lower priority", which seems odd to me, as closing it means it's no longer being tracked as a priority of any level. Has there been any actual progress on this?

digitalseraphim avatar Jan 04 '22 19:01 digitalseraphim

@digitalseraphim Sure, I could open a new bug internally, but I'm not able to repro a bug with 1.7.1...maybe I'm not doing the repro correctly? I tried with https://github.com/abseil/abseil-cpp using test code at https://github.com/fcharlie/abslexample/blob/master/main/main.cc and clang on Ubuntu 20 with clang++ 10 (also on Windows with clang and mingw/gcc).

sean-mcmanus avatar Jan 05 '22 19:01 sean-mcmanus

I'll have to see if I can try that version. Didn't see anything about this issue being fixed anywhere, so I didn't try that. I'll respond back if I'm able to try it out. Thanks!

digitalseraphim avatar Jan 05 '22 21:01 digitalseraphim

@digitalseraphim Which "version" are you referring to? With 0.23.1 of our extension I get a squiggle error (but a different one from the original report) and they're fixed with 1.7.1 -- if anyone is getting squiggles with 1.7.1, I need to know which version of clang or gcc and which version of the abseil library is being used (I'm guessing the original errors aren't reproing because I'm using a newer version of the abseil library).

sean-mcmanus avatar Jan 07 '22 14:01 sean-mcmanus

I'm using version 1.1.3 of cpptools, clang-9 on the system, and I'm getting the 'enable_if' attributes with conditions that are not constant values... error.

digitalseraphim avatar Jan 07 '22 15:01 digitalseraphim

@digitalseraphim Yeah, I repro that with 1.1.3 -- it's fixed with 1.7.1. Not sure exactly which version update got the fix -- we get IntelliSense parser fixes with every release and we don't always get the fixes matched with a bug report on GitHub.

sean-mcmanus avatar Jan 07 '22 15:01 sean-mcmanus

Cool, thanks for the update! I'll work on getting that version. Have a great day!

On Fri, Jan 7, 2022, 10:48 AM Sean McManus @.***> wrote:

@digitalseraphim https://github.com/digitalseraphim Yeah, I repro that with 1.1.3 -- it's fixed with 1.7.1. Not sure exactly which version update got the fix -- we get IntelliSense parser fixes with every release and we don't always get the fixes matched with a bug report on GitHub.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-cpptools/issues/3683#issuecomment-1007513005, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4DK3HSMKRVSYBDAX2U3DUU4DLRANCNFSM4HPM2MTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

digitalseraphim avatar Jan 07 '22 15:01 digitalseraphim

I use version 1.8.0 (prerelease) and I use the latest release of abseil https://github.com/abseil/abseil-cpp/archive/20211102.0.zip

I can confirm that the problem still persists.

image

If you tell me how one could differentiate between the intellisense compilation and the regular clang compilation, I could try to submit a PR to abseil that disables the use of enabled_if under vscode intellisense as a workaround. @sean-mcmanus

romange avatar Jan 21 '22 17:01 romange

@romange Okay, I got the repro now -- I have to edit a line to get in the function to get the error to appear. I'll look into filing a bug on our shared parser so this can eventually get fixed.

You can use #ifndef __INTELLISENSE__ to have IntelliSense skip code or

#ifdef __INTELLISENSE__
    #pragma diag_suppress <error code>
#endif

to suppress specific errors.

sean-mcmanus avatar Jan 21 '22 18:01 sean-mcmanus

Thanks @sean-mcmanus . Meanwhile, I submitted https://github.com/abseil/abseil-cpp/pull/1097 to work around the issue.

romange avatar Jan 21 '22 18:01 romange

I've filed an internal bug against our shared parser with VS (1042595).

sean-mcmanus avatar Jan 21 '22 19:01 sean-mcmanus

Updating that my fix to abseil was merged into master. For those who use stables releases of the library and do not want to wait another 6 months for the next release, I just apply a patch like this one on checkout.

romange avatar Jan 27 '22 18:01 romange

'enable_if' attributes with conditions that are not constant values are not currently supported. Any update on this bug? I'm having the same problem.

phyBrackets avatar Feb 27 '22 19:02 phyBrackets

The bug is filed against our parser -- the fix won't be available for 1.9, but it's possible it could for 1.10.

sean-mcmanus avatar Feb 28 '22 22:02 sean-mcmanus

I still have this enable_if issue with VS Code 1.68.0 and C/C++ Extension Version 1.10.7 (from 6/16/2022). I am encountering this on the LLVM project with this constructor: https://github.com/llvm/llvm-project/blob/dc562d570dfe7589a27497c1210b105d9d8603f0/llvm/include/llvm/ADT/StringRef.h#L925 Same error message: 'enable_if' attributes with conditions that are not constant values are not currently supportedC/C++(2817) When using clang++ 14.0.3, I can compile code that uses this constructor (e.g. llvm::StringRef test("test");) just fine, so I know that the compiler can support it. Any update on the bug progress?

emosy avatar Jun 20 '22 15:06 emosy

@emosy Our IntelliSense compiler is based on the EDG compiler (emulating clang) and not the actual clang compiler, so we're waiting for a bug fix from that development team -- this may have gotten raised to a P1 a month ago, but I'm not aware of an ETA still.

sean-mcmanus avatar Jun 20 '22 21:06 sean-mcmanus

@emosy FYI, the fix is too late for our 1.11.3 release next week, but it should be in the next 1.12.0 insiders release, maybe a week or two later.

sean-mcmanus avatar Jul 14 '22 20:07 sean-mcmanus

Thank you!

emosy avatar Jul 15 '22 14:07 emosy