Open farzonl opened 10 months ago
I'd probably change this to be something more like:
CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
const char *ast_filename) {
#if 1
return CXTranslationUnit();
#else
CXTranslationUnit TU;
enum CXErrorCode Result =
clang_createTranslationUnit2(CIdx, ast_filename, &TU);
(void)Result;
assert((TU && Result == CXError_Success) ||
(!TU && Result != CXError_Success));
return TU;
#endif
}
Everything else in the function is effectively unused.
@farzonl feel like making a PR?
Description A preprocessor defintion to block out code not needed for dxc means that
TU
is expected to be set viaclang_createTranslationUnit2
's*out_TU = MakeCXTranslationUnit(CXXIdx, AU.release());
Even though it is not necessary for it to do so becauseCXTranslationUnit TU;
is return by value viaclang_createTranslationUnit
.https://github.com/microsoft/DirectXShaderCompiler/blob/ceff9b8043df3ac8d7d3ce71b409d83afcd7925b/tools/clang/tools/libclang/CIndex.cpp#L2944:2961
While this is a false positive it is the only case in chromium third party (https://chromium.googlesource.com/external/github.com/microsoft/DirectXShaderCompiler) that violates this rule.
An altenative:
This way you avoid calling
clang_createTranslationUnit2
entirely.