我已经为 C++11 在其持续构建过程中的使用配置了 Eclipse CDT(Eclipse v4.5.0,构建 ID 20150621-1200;CDT v8.7.0.201506070905),但某些表达式仍然会导致语义错误,即使它们编译正确使用 g++ 4.9.2 和 clang++ 3.8.0。也就是说,作为函数参数提供的大括号初始化列表与参数的相应std::initializer_list
构造函数不匹配,并且 LLVMcast
函数的正确版本也不与其提供的参数匹配。Eclipse CDT 是否使用不支持此类 C++11 功能的较旧的内部解析器,而不是委托给它检测到的更现代的外部 GCC 工具链?
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
using namespace llvm;
// i32 @myFunc1(i32, i32), i32 @myFunc2(i32, i32)
SmallVector<Function*, 2> getMyFuncs(Module& M) {
Type* i32 = Type::getInt32Ty(M.getContext());
// error #1 reported
FunctionType* FT = FunctionType::get(i32, {i32, i32}, false);
// error #2 reported
Function* F1 = cast<Function>(M.getOrInsertFunction("myFunc1", FT));
// no error with implicit matching of ArrayRef(const std::initializer_list<T>&) here
ArrayRef<Type*> ArgTypes = {i32, i32};
FT = FunctionType::get(i32, ArgTypes, false);
// error #2 reported
Function* F2 = cast<Function>(M.getOrInsertFunction("myFunc2", FT));
// no error with implicit matching of SmallVector(std::initializer_list<T>) here
return {F1, F2};
}
错误 #1
无效参数 '
候选者是:
llvm::FunctionType * get(llvm::Type *, llvm::ArrayRef, bool)
llvm::FunctionType * get(llvm::Type *, bool)
错误 #2
无效参数 '
候选者是:
llvm::cast_retty<#0,#1 *>::ret_type cast(#1 *) std::enable_if::ret_type>::type cast(const #1 &)
llvm::cast_retty< #0,#1>::ret_type cast(#1 &)
'