Qt Creator clang 代码模型 "could not parse an included file" 派生模板中的警告和错误 类

Qt Creator clang code model "could not parse an included file" warning and errors in derived template classes

我在 Qt Creator 中使用 clang 代码模型。它总是工作正常,包括我重写从模板库 class 派生的 class 中的方法以及使用 C++17 功能时的情况。然后我切换到 Qt Creator 4.5,突然我得到了错误 "only virtual member functions can be marked 'override'" 即使代码没有改变。

现在我尝试回到 Qt Creator 4.4 并删除所有设置,但它仍然是一样的。

最重要的是,当我打开一个新文件时,我收到警告 "The code model could not parse an included file, which might lead to slow or incorrect code completion and highlighting, for example. type_traits:3083:7: error: expected '(' for function-style cast or type construction" 并收到错误“错误:名称空间 'std' 中没有名为 'optional' 的类型。

这只会影响代码模型,即。 Qt Creator 在 IDE 中显示的警告和错误。编译仍然正常。

这是我对代码模型的配置:

-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-missing-prototypes -Wno-c++11-extensions -std=c++1z

我在设置和不设置 std 的情况下都进行了尝试,但这并没有改变任何东西。

这是一个导致 "error: use of undeclared identifier 'std'"、"error: expected '(' for function-style cast or type constrcution" 和 "error: use of undeclared identifier 'x'" 的最小示例:

#pragma once

#include <optional>

class Test {
public:
    void bar() {
        std::optional<int> x;
    }
};

有什么线索可能已经改变或我可能遗漏了哪些设置吗?

这似乎是 Qt Creator 的问题。 4.6版本已经解决,使用更新版本的clang