Skip to content

Commit

Permalink
[NFC][AST] Return void from setUseQualifiedLookup
Browse files Browse the repository at this point in the history
It uses to initialize the class. If so, it returns uninitalized value.
This is UB and msan with -fno-inline will complain.
  • Loading branch information
vitalybuka committed May 12, 2023
1 parent 8cb8262 commit ba566ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions clang/include/clang/AST/DeclBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2540,10 +2540,8 @@ class DeclContext {
D == LastDecl);
}

bool setUseQualifiedLookup(bool use = true) const {
bool old_value = DeclContextBits.UseQualifiedLookup;
void setUseQualifiedLookup(bool use = true) const {
DeclContextBits.UseQualifiedLookup = use;
return old_value;
}

bool shouldUseQualifiedLookup() const {
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/SemaLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2424,8 +2424,9 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
bool oldVal;
DeclContext *Context;
// Set flag in DeclContext informing debugger that we're looking for qualified name
QualifiedLookupInScope(DeclContext *ctx) : Context(ctx) {
oldVal = ctx->setUseQualifiedLookup();
QualifiedLookupInScope(DeclContext *ctx)
: oldVal(ctx->shouldUseQualifiedLookup()), Context(ctx) {
ctx->setUseQualifiedLookup();
}
~QualifiedLookupInScope() {
Context->setUseQualifiedLookup(oldVal);
Expand Down

0 comments on commit ba566ff

Please sign in to comment.