llvm / llvm/llvm-project

Pragma Parser uses to sets of uniqe_ptr to handle the same pointer

Open
#183,429 9 comments 0 reactions 0 assignees View on GitHub
clang:frontend quality-of-implementation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Static analysis flagged one of these lines:

https://github.com/llvm/llvm-project/blob/564f433083d1f723ee8157afffa1f1313fb596b4/clang/lib/Parse/ParsePragma.cpp#L423

saying that create an `unique_ptr` to manage a pointer:

https://github.com/llvm/llvm-project/blob/564f433083d1f723ee8157afffa1f1313fb596b4/clang/lib/Parse/ParsePragma.cpp#L422

and then `PP.AddPragmaHandler` will also take the raw pointer it gets and create a new `unique_ptr` to manage it. For example here:

https://github.com/llvm/llvm-project/blob/564f433083d1f723ee8157afffa1f1313fb596b4/clang/lib/Lex/Pragma.cpp#L935

Now it looks like these `unique_ptr` are just manually reset later on, so I think this just works but it does indeed look odd.

Contributor guide

Open the contributing guide

Research direction

Inspect clang/lib/Parse/ParsePragma.cpp at lines 422-423 and clang/lib/Lex/Pragma.cpp at line 935, then trace how the handlers are owned and later reset. Confirm whether the same pointer can be managed by two unique_ptr instances, and consider the issue done when ownership is unambiguous and the static-analysis concern is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.