github / github/codeql

Make it more ergonomic to get the initializer of a variable declaration in C++

Offen
#7,275 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
C++ question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

I would expect that if I have a `DeclStmt` or a `DeclarationEntry`, I should be able to directly get the `Initializer`s corresponding to those entries, if they exist. I don't see a way to directly do that, and currently I have to resort to this:
```codeql
Initializer getDeclStmtInitializer(DeclStmt ds) {
result.getDeclaration().getADeclarationEntry() = ds.getADeclarationEntry()
}
```

Could we add some methods into the standard library classes (i.e. `DeclStmt::getAnInitializer`, `Declaration::getAnInitializer` `DeclarationEntry::getInitializer()`, etc.), to make it easier to get variable declaration initializers so we don't have to resort to these types of helper functions?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.