TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:
FullLoc.getManager().someMethod(FullLoc.getLocation());
instead we have:
FullLoc.someMethod();
Modified TextDiagnostics (and related classes) to use this short-hand.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44957 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Lex/LiteralSupport.cpp b/Lex/LiteralSupport.cpp
index d00d9c3..0313823 100644
--- a/Lex/LiteralSupport.cpp
+++ b/Lex/LiteralSupport.cpp
@@ -93,8 +93,10 @@
}
// See if any bits will be truncated when evaluated as a character.
- unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
- : PP.getTargetInfo().getCharWidth(Loc);
+ unsigned CharWidth = IsWide
+ ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc))
+ : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc));
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
Overflow = true;
ResultChar &= ~0U >> (32-CharWidth);
@@ -122,8 +124,10 @@
ThisTokBuf[0] >= '0' && ThisTokBuf[0] <= '7');
// Check for overflow. Reject '\777', but not L'\777'.
- unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
- : PP.getTargetInfo().getCharWidth(Loc);
+ unsigned CharWidth = IsWide
+ ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc))
+ : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc));
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
PP.Diag(Loc, diag::warn_octal_escape_too_large);
ResultChar &= ~0U >> (32-CharWidth);
@@ -453,13 +457,13 @@
// FIXME: This assumes that 'int' is 32-bits in overflow calculation, and the
// size of "value".
- assert(PP.getTargetInfo().getIntWidth(Loc) == 32 &&
+ assert(PP.getTargetInfo().getIntWidth(PP.getFullLoc(Loc)) == 32 &&
"Assumes sizeof(int) == 4 for now");
// FIXME: This assumes that wchar_t is 32-bits for now.
- assert(PP.getTargetInfo().getWCharWidth(Loc) == 32 &&
+ assert(PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc)) == 32 &&
"Assumes sizeof(wchar_t) == 4 for now");
// FIXME: This extensively assumes that 'char' is 8-bits.
- assert(PP.getTargetInfo().getCharWidth(Loc) == 8 &&
+ assert(PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc)) == 8 &&
"Assumes char is 8 bits");
bool isFirstChar = true;
@@ -505,7 +509,7 @@
// character constants are not sign extended in the this implementation:
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
if (!IsWide && !isMultiChar && (Value & 128) &&
- PP.getTargetInfo().isCharSigned(Loc))
+ PP.getTargetInfo().isCharSigned(PP.getFullLoc(Loc)))
Value = (signed char)Value;
}
@@ -583,7 +587,9 @@
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
wchar_tByteWidth = ~0U;
if (AnyWide) {
- wchar_tByteWidth = Target.getWCharWidth(StringToks[0].getLocation());
+ wchar_tByteWidth =
+ Target.getWCharWidth(PP.getFullLoc(StringToks[0].getLocation()));
+
assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!");
wchar_tByteWidth /= 8;
}
diff --git a/Lex/PPExpressions.cpp b/Lex/PPExpressions.cpp
index ec20eb1..ff0c36c 100644
--- a/Lex/PPExpressions.cpp
+++ b/Lex/PPExpressions.cpp
@@ -112,15 +112,17 @@
if (Macro->isTargetSpecific()) {
// Don't warn on second use.
Macro->setIsTargetSpecific(false);
- PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
- diag::port_target_macro_use);
+ PP.getTargetInfo().DiagnoseNonPortability(
+ PP.getFullLoc(PeekTok.getLocation()),
+ diag::port_target_macro_use);
}
} else if (ValueLive) {
// Use of a target-specific macro for some other target? If so, warn.
if (II->isOtherTargetMacro()) {
II->setIsOtherTargetMacro(false); // Don't warn on second use.
- PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
- diag::port_target_macro_use);
+ PP.getTargetInfo().DiagnoseNonPortability(
+ PP.getFullLoc(PeekTok.getLocation()),
+ diag::port_target_macro_use);
}
}
@@ -211,16 +213,16 @@
TargetInfo &TI = PP.getTargetInfo();
unsigned NumBits;
if (Literal.isWide())
- NumBits = TI.getWCharWidth(PeekTok.getLocation());
+ NumBits = TI.getWCharWidth(PP.getFullLoc(PeekTok.getLocation()));
else
- NumBits = TI.getCharWidth(PeekTok.getLocation());
+ NumBits = TI.getCharWidth(PP.getFullLoc(PeekTok.getLocation()));
// Set the width.
llvm::APSInt Val(NumBits);
// Set the value.
Val = Literal.getValue();
// Set the signedness.
- Val.setIsUnsigned(!TI.isCharSigned(PeekTok.getLocation()));
+ Val.setIsUnsigned(!TI.isCharSigned(PP.getFullLoc(PeekTok.getLocation())));
if (Result.getBitWidth() > Val.getBitWidth()) {
if (Val.isSigned())
@@ -617,7 +619,9 @@
Lex(Tok);
// C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t.
- unsigned BitWidth = getTargetInfo().getIntMaxTWidth(Tok.getLocation());
+ unsigned BitWidth =
+ getTargetInfo().getIntMaxTWidth(getFullLoc(Tok.getLocation()));
+
llvm::APSInt ResVal(BitWidth);
DefinedTracker DT;
if (EvaluateValue(ResVal, Tok, DT, true, *this)) {
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index 51d8e5d..fb4628b 100644
--- a/Lex/Preprocessor.cpp
+++ b/Lex/Preprocessor.cpp
@@ -120,12 +120,12 @@
/// the specified Token's location, translating the token's start
/// position in the current buffer into a SourcePosition object for rendering.
void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID) {
- Diags.Report(Loc, DiagID, SourceMgr);
+ Diags.Report(getFullLoc(Loc), DiagID);
}
void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg) {
- Diags.Report(Loc, DiagID, SourceMgr, &Msg, 1);
+ Diags.Report(getFullLoc(Loc), DiagID, &Msg, 1);
}
void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
@@ -791,7 +791,7 @@
// If this is the first use of a target-specific macro, warn about it.
if (MI->isTargetSpecific()) {
MI->setIsTargetSpecific(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(),
+ getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()),
diag::port_target_macro_use);
}
@@ -1227,7 +1227,7 @@
// This diagnosic is only emitted when macro expansion is enabled, because
// the macro would not have been expanded for the other target either.
II.setIsOtherTargetMacro(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(),
+ getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()),
diag::port_target_macro_use);
}
@@ -2337,15 +2337,17 @@
// If this is the first use of a target-specific macro, warn about it.
if (MI->isTargetSpecific()) {
MI->setIsTargetSpecific(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(),
- diag::port_target_macro_use);
+ getTargetInfo().DiagnoseNonPortability(
+ getFullLoc(MacroNameTok.getLocation()),
+ diag::port_target_macro_use);
}
} else {
// Use of a target-specific macro for some other target? If so, warn.
if (MII->isOtherTargetMacro()) {
MII->setIsOtherTargetMacro(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(),
- diag::port_target_macro_use);
+ getTargetInfo().DiagnoseNonPortability(
+ getFullLoc(MacroNameTok.getLocation()),
+ diag::port_target_macro_use);
}
}