Refactor ClangUserExpression::GetLanguageForExpr
authorRaphael Isemann <teemperor@gmail.com>
Thu, 27 Sep 2018 10:12:54 +0000 (10:12 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Thu, 27 Sep 2018 10:12:54 +0000 (10:12 +0000)
commitdababf70e2df03214b19c0bfaeb6091923171ef6
treeb3d8eab9026b8e5fa6c571f007ad9cc526bae30a
parent436c0127025aab9e470cb20f678c4ecf28cfa765
Refactor ClangUserExpression::GetLanguageForExpr

Summary:
The `ClangUserExpression::GetLanguageForExpr` method is currently a big
source of sadness, as it's name implies that it's an accessor method, but it actually
is also initializing some variables that we need for parsing. This caused that we
currently call this getter just for it's side effects while ignoring it's return value,
which is confusing for the reader.

This patch renames it to `UpdateLanguageForExpr` and merges all calls to the
method into a single call in `ClangUserExpression::PrepareForParsing` (as calling
this method is anyway mandatory for parsing to succeed)

While looking at the code, I also found that we actually have two language
variables in this class hierarchy. The normal `Language` from the UserExpression
class and the `LanguageForExpr` that we implemented in this subclass. Both
don't seem to actually contain the same value, so we probably should look at this
next.

Reviewers: xbolva00

Reviewed By: xbolva00

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D52561

llvm-svn: 343191
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h