Simplify an API

llvm-svn: 38541
This commit is contained in:
Chris Lattner 2006-06-18 06:50:36 +00:00
parent cb28334ea4
commit 7966aafd9b
3 changed files with 8 additions and 14 deletions

View File

@ -30,21 +30,18 @@ using namespace clang;
///
/// MinPrec is the minimum precedence that this range of the expression is
/// allowed to include.
void Preprocessor::EvaluateDirectiveExpression(bool &Result) {
bool Preprocessor::EvaluateDirectiveExpression() {
// Peek ahead one token.
LexerToken Tok;
Lex(Tok);
// In error cases, bail out with false value.
Result = false;
int ResVal = 0;
if (EvaluateValue(ResVal, Tok) ||
EvaluateDirectiveSubExpr(ResVal, 1, Tok)) {
// Skip the rest of the macro line.
if (Tok.getKind() != tok::eom)
DiscardUntilEndOfDirective();
return;
return false;
}
// If we aren't at the tok::eom token, something bad happened, like an extra
@ -54,7 +51,7 @@ void Preprocessor::EvaluateDirectiveExpression(bool &Result) {
DiscardUntilEndOfDirective();
}
Result = ResVal != 0;
return ResVal != 0;
}
/// EvaluateValue - Evaluate the token PeekTok (and any others needed) and

View File

@ -621,7 +621,7 @@ void Preprocessor::SkipExcludedConditionalBlock(const char *IfTokenLoc,
// looked up, etc, inside the #elif expression.
assert(SkippingContents && "We have to be skipping here!");
SkippingContents = false;
EvaluateDirectiveExpression(ShouldEnter);
ShouldEnter = EvaluateDirectiveExpression();
SkippingContents = true;
}
@ -1011,8 +1011,7 @@ void Preprocessor::HandleIfDirective(LexerToken &IfToken) {
++NumIf;
const char *Start = CurLexer->BufferPtr;
bool ConditionalTrue = false;
EvaluateDirectiveExpression(ConditionalTrue);
bool ConditionalTrue = EvaluateDirectiveExpression();
// Should we include the stuff contained by this directive?
if (ConditionalTrue) {

View File

@ -332,12 +332,10 @@ private:
/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
/// may occur after a #if or #elif directive. Sets Result to the result of
/// the expression.
void EvaluateDirectiveExpression(bool &Result);
/// EvaluateValue - Used to implement EvaluateDirectiveExpression,
/// see PPExpressions.cpp.
bool EvaluateDirectiveExpression();
/// EvaluateValue/EvaluateDirectiveSubExpr - Used to implement
/// EvaluateDirectiveExpression, see PPExpressions.cpp.
bool EvaluateValue(int &Result, LexerToken &PeekTok);
/// EvaluateDirectiveSubExpr - Used to implement EvaluateDirectiveExpression,
/// see PPExpressions.cpp.
bool EvaluateDirectiveSubExpr(int &LHS, unsigned MinPrec,
LexerToken &PeekTok);