microsoft / microsoft/DirectXShaderCompiler
ClangTidy: clang-analyzer-core.uninitialized.Branch in third_party/dawn/third_party/dxc/tools/clang/tools/libclang/CIndex.cpp
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
A preprocessor defintion to block out code not needed for dxc means that TU is expected to be set via
clang_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 via clang_createTranslationUnit.
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:
CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
const char *ast_filename) {
CXTranslationUnit TU;
#if 1 // HLSL Change Starts - no support for serialization
enum CXErrorCode Result = CXError_Failure;
#else
enum CXErrorCode Result =
clang_createTranslationUnit2(CIdx, ast_filename, &TU);
#endif // HLSL Change Ends - no support for serialization
(void)Result;
assert((TU && Result == CXError_Success) ||
(!TU && Result != CXError_Success));
return TU;
}
This way you avoid calling clang_createTranslationUnit2 entirely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in third_party/dawn/third_party/dxc/tools/clang/tools/libclang/CIndex.cpp around lines 2944-2961, focusing on clang_createTranslationUnit and clang_createTranslationUnit2. Review the preprocessor-controlled path and the proposed alternative, then verify that the clang-analyzer-core.uninitialized.Branch warning is resolved without changing the translation-unit behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100