forked from OSchip/llvm-project
Rename CodeModificationHint to FixItHint, since we've been using the
term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
This commit is contained in:
parent
9e2e1c9024
commit
3baad0d4f7
|
@ -14,6 +14,8 @@
|
||||||
#ifndef LLVM_CLANG_AST_STATISTICS_H
|
#ifndef LLVM_CLANG_AST_STATISTICS_H
|
||||||
#define LLVM_CLANG_AST_STATISTICS_H
|
#define LLVM_CLANG_AST_STATISTICS_H
|
||||||
|
|
||||||
|
#define CLANG_C_ONLY 1
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
|
@ -35,7 +37,16 @@ struct isa_impl<clang::Type, From> { \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
}
|
}
|
||||||
|
#elif defined(CLANG_C_ONLY)
|
||||||
|
#define CLANG_ISA_STATISTIC(Type,Counter) \
|
||||||
|
namespace llvm { \
|
||||||
|
template <typename From> \
|
||||||
|
struct isa_impl<clang::Type, From> { \
|
||||||
|
static inline bool doit(const From &Val) __attribute__((always_inline)) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define CLANG_ISA_STATISTIC(Type,Counter)
|
#define CLANG_ISA_STATISTIC(Type,Counter)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace clang {
|
||||||
/// should also provide full recovery from such errors, such that
|
/// should also provide full recovery from such errors, such that
|
||||||
/// suppressing the diagnostic output can still result in successful
|
/// suppressing the diagnostic output can still result in successful
|
||||||
/// compilation.
|
/// compilation.
|
||||||
class CodeModificationHint {
|
class FixItHint {
|
||||||
public:
|
public:
|
||||||
/// \brief Tokens that should be removed to correct the error.
|
/// \brief Tokens that should be removed to correct the error.
|
||||||
SourceRange RemoveRange;
|
SourceRange RemoveRange;
|
||||||
|
@ -110,7 +110,7 @@ public:
|
||||||
|
|
||||||
/// \brief Empty code modification hint, indicating that no code
|
/// \brief Empty code modification hint, indicating that no code
|
||||||
/// modification is known.
|
/// modification is known.
|
||||||
CodeModificationHint() : RemoveRange(), InsertionLoc() { }
|
FixItHint() : RemoveRange(), InsertionLoc() { }
|
||||||
|
|
||||||
bool isNull() const {
|
bool isNull() const {
|
||||||
return !RemoveRange.isValid() && !InsertionLoc.isValid();
|
return !RemoveRange.isValid() && !InsertionLoc.isValid();
|
||||||
|
@ -118,9 +118,9 @@ public:
|
||||||
|
|
||||||
/// \brief Create a code modification hint that inserts the given
|
/// \brief Create a code modification hint that inserts the given
|
||||||
/// code string at a specific location.
|
/// code string at a specific location.
|
||||||
static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc,
|
static FixItHint CreateInsertion(SourceLocation InsertionLoc,
|
||||||
llvm::StringRef Code) {
|
llvm::StringRef Code) {
|
||||||
CodeModificationHint Hint;
|
FixItHint Hint;
|
||||||
Hint.InsertionLoc = InsertionLoc;
|
Hint.InsertionLoc = InsertionLoc;
|
||||||
Hint.CodeToInsert = Code;
|
Hint.CodeToInsert = Code;
|
||||||
return Hint;
|
return Hint;
|
||||||
|
@ -128,17 +128,17 @@ public:
|
||||||
|
|
||||||
/// \brief Create a code modification hint that removes the given
|
/// \brief Create a code modification hint that removes the given
|
||||||
/// source range.
|
/// source range.
|
||||||
static CodeModificationHint CreateRemoval(SourceRange RemoveRange) {
|
static FixItHint CreateRemoval(SourceRange RemoveRange) {
|
||||||
CodeModificationHint Hint;
|
FixItHint Hint;
|
||||||
Hint.RemoveRange = RemoveRange;
|
Hint.RemoveRange = RemoveRange;
|
||||||
return Hint;
|
return Hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Create a code modification hint that replaces the given
|
/// \brief Create a code modification hint that replaces the given
|
||||||
/// source range with the given code string.
|
/// source range with the given code string.
|
||||||
static CodeModificationHint CreateReplacement(SourceRange RemoveRange,
|
static FixItHint CreateReplacement(SourceRange RemoveRange,
|
||||||
llvm::StringRef Code) {
|
llvm::StringRef Code) {
|
||||||
CodeModificationHint Hint;
|
FixItHint Hint;
|
||||||
Hint.RemoveRange = RemoveRange;
|
Hint.RemoveRange = RemoveRange;
|
||||||
Hint.InsertionLoc = RemoveRange.getBegin();
|
Hint.InsertionLoc = RemoveRange.getBegin();
|
||||||
Hint.CodeToInsert = Code;
|
Hint.CodeToInsert = Code;
|
||||||
|
@ -519,8 +519,8 @@ private:
|
||||||
/// NumRanges - This is the number of ranges in the DiagRanges array.
|
/// NumRanges - This is the number of ranges in the DiagRanges array.
|
||||||
unsigned char NumDiagRanges;
|
unsigned char NumDiagRanges;
|
||||||
/// \brief The number of code modifications hints in the
|
/// \brief The number of code modifications hints in the
|
||||||
/// CodeModificationHints array.
|
/// FixItHints array.
|
||||||
unsigned char NumCodeModificationHints;
|
unsigned char NumFixItHints;
|
||||||
|
|
||||||
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
|
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
|
||||||
/// values, with one for each argument. This specifies whether the argument
|
/// values, with one for each argument. This specifies whether the argument
|
||||||
|
@ -542,11 +542,11 @@ private:
|
||||||
/// only support 10 ranges, could easily be extended if needed.
|
/// only support 10 ranges, could easily be extended if needed.
|
||||||
SourceRange DiagRanges[10];
|
SourceRange DiagRanges[10];
|
||||||
|
|
||||||
enum { MaxCodeModificationHints = 3 };
|
enum { MaxFixItHints = 3 };
|
||||||
|
|
||||||
/// CodeModificationHints - If valid, provides a hint with some code
|
/// FixItHints - If valid, provides a hint with some code
|
||||||
/// to insert, remove, or modify at a particular position.
|
/// to insert, remove, or modify at a particular position.
|
||||||
CodeModificationHint CodeModificationHints[MaxCodeModificationHints];
|
FixItHint FixItHints[MaxFixItHints];
|
||||||
|
|
||||||
/// ProcessDiag - This is the method used to report a diagnostic that is
|
/// ProcessDiag - This is the method used to report a diagnostic that is
|
||||||
/// finally fully formed.
|
/// finally fully formed.
|
||||||
|
@ -573,13 +573,12 @@ private:
|
||||||
/// for example.
|
/// for example.
|
||||||
class DiagnosticBuilder {
|
class DiagnosticBuilder {
|
||||||
mutable Diagnostic *DiagObj;
|
mutable Diagnostic *DiagObj;
|
||||||
mutable unsigned NumArgs, NumRanges, NumCodeModificationHints;
|
mutable unsigned NumArgs, NumRanges, NumFixItHints;
|
||||||
|
|
||||||
void operator=(const DiagnosticBuilder&); // DO NOT IMPLEMENT
|
void operator=(const DiagnosticBuilder&); // DO NOT IMPLEMENT
|
||||||
friend class Diagnostic;
|
friend class Diagnostic;
|
||||||
explicit DiagnosticBuilder(Diagnostic *diagObj)
|
explicit DiagnosticBuilder(Diagnostic *diagObj)
|
||||||
: DiagObj(diagObj), NumArgs(0), NumRanges(0),
|
: DiagObj(diagObj), NumArgs(0), NumRanges(0), NumFixItHints(0) {}
|
||||||
NumCodeModificationHints(0) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Copy constructor. When copied, this "takes" the diagnostic info from the
|
/// Copy constructor. When copied, this "takes" the diagnostic info from the
|
||||||
|
@ -589,7 +588,7 @@ public:
|
||||||
D.DiagObj = 0;
|
D.DiagObj = 0;
|
||||||
NumArgs = D.NumArgs;
|
NumArgs = D.NumArgs;
|
||||||
NumRanges = D.NumRanges;
|
NumRanges = D.NumRanges;
|
||||||
NumCodeModificationHints = D.NumCodeModificationHints;
|
NumFixItHints = D.NumFixItHints;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Simple enumeration value used to give a name to the
|
/// \brief Simple enumeration value used to give a name to the
|
||||||
|
@ -599,7 +598,7 @@ public:
|
||||||
/// \brief Create an empty DiagnosticBuilder object that represents
|
/// \brief Create an empty DiagnosticBuilder object that represents
|
||||||
/// no actual diagnostic.
|
/// no actual diagnostic.
|
||||||
explicit DiagnosticBuilder(SuppressKind)
|
explicit DiagnosticBuilder(SuppressKind)
|
||||||
: DiagObj(0), NumArgs(0), NumRanges(0), NumCodeModificationHints(0) { }
|
: DiagObj(0), NumArgs(0), NumRanges(0), NumFixItHints(0) { }
|
||||||
|
|
||||||
/// \brief Force the diagnostic builder to emit the diagnostic now.
|
/// \brief Force the diagnostic builder to emit the diagnostic now.
|
||||||
///
|
///
|
||||||
|
@ -648,14 +647,14 @@ public:
|
||||||
DiagObj->DiagRanges[NumRanges++] = R;
|
DiagObj->DiagRanges[NumRanges++] = R;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCodeModificationHint(const CodeModificationHint &Hint) const {
|
void AddFixItHint(const FixItHint &Hint) const {
|
||||||
if (Hint.isNull())
|
if (Hint.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(NumCodeModificationHints < Diagnostic::MaxCodeModificationHints &&
|
assert(NumFixItHints < Diagnostic::MaxFixItHints &&
|
||||||
"Too many code modification hints!");
|
"Too many fix-it hints!");
|
||||||
if (DiagObj)
|
if (DiagObj)
|
||||||
DiagObj->CodeModificationHints[NumCodeModificationHints++] = Hint;
|
DiagObj->FixItHints[NumFixItHints++] = Hint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -716,8 +715,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
||||||
const CodeModificationHint &Hint) {
|
const FixItHint &Hint) {
|
||||||
DB.AddCodeModificationHint(Hint);
|
DB.AddFixItHint(Hint);
|
||||||
return DB;
|
return DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,17 +812,17 @@ public:
|
||||||
return DiagObj->DiagRanges[Idx];
|
return DiagObj->DiagRanges[Idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getNumCodeModificationHints() const {
|
unsigned getNumFixItHints() const {
|
||||||
return DiagObj->NumCodeModificationHints;
|
return DiagObj->NumFixItHints;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeModificationHint &getCodeModificationHint(unsigned Idx) const {
|
const FixItHint &getFixItHint(unsigned Idx) const {
|
||||||
return DiagObj->CodeModificationHints[Idx];
|
return DiagObj->FixItHints[Idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeModificationHint *getCodeModificationHints() const {
|
const FixItHint *getFixItHints() const {
|
||||||
return DiagObj->NumCodeModificationHints?
|
return DiagObj->NumFixItHints?
|
||||||
&DiagObj->CodeModificationHints[0] : 0;
|
&DiagObj->FixItHints[0] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FormatDiagnostic - Format this diagnostic into a string, substituting the
|
/// FormatDiagnostic - Format this diagnostic into a string, substituting the
|
||||||
|
@ -846,7 +845,7 @@ class StoredDiagnostic {
|
||||||
FullSourceLoc Loc;
|
FullSourceLoc Loc;
|
||||||
std::string Message;
|
std::string Message;
|
||||||
std::vector<SourceRange> Ranges;
|
std::vector<SourceRange> Ranges;
|
||||||
std::vector<CodeModificationHint> FixIts;
|
std::vector<FixItHint> FixIts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StoredDiagnostic();
|
StoredDiagnostic();
|
||||||
|
@ -866,7 +865,7 @@ public:
|
||||||
range_iterator range_end() const { return Ranges.end(); }
|
range_iterator range_end() const { return Ranges.end(); }
|
||||||
unsigned range_size() const { return Ranges.size(); }
|
unsigned range_size() const { return Ranges.size(); }
|
||||||
|
|
||||||
typedef std::vector<CodeModificationHint>::const_iterator fixit_iterator;
|
typedef std::vector<FixItHint>::const_iterator fixit_iterator;
|
||||||
fixit_iterator fixit_begin() const { return FixIts.begin(); }
|
fixit_iterator fixit_begin() const { return FixIts.begin(); }
|
||||||
fixit_iterator fixit_end() const { return FixIts.end(); }
|
fixit_iterator fixit_end() const { return FixIts.end(); }
|
||||||
unsigned fixit_size() const { return FixIts.size(); }
|
unsigned fixit_size() const { return FixIts.size(); }
|
||||||
|
|
|
@ -29,8 +29,7 @@ class DeclarationName;
|
||||||
class PartialDiagnostic {
|
class PartialDiagnostic {
|
||||||
public:
|
public:
|
||||||
struct Storage {
|
struct Storage {
|
||||||
Storage() : NumDiagArgs(0), NumDiagRanges(0), NumCodeModificationHints(0) {
|
Storage() : NumDiagArgs(0), NumDiagRanges(0), NumFixItHints(0) { }
|
||||||
}
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/// MaxArguments - The maximum number of arguments we can hold. We
|
/// MaxArguments - The maximum number of arguments we can hold. We
|
||||||
|
@ -47,8 +46,8 @@ public:
|
||||||
unsigned char NumDiagRanges;
|
unsigned char NumDiagRanges;
|
||||||
|
|
||||||
/// \brief The number of code modifications hints in the
|
/// \brief The number of code modifications hints in the
|
||||||
/// CodeModificationHints array.
|
/// FixItHints array.
|
||||||
unsigned char NumCodeModificationHints;
|
unsigned char NumFixItHints;
|
||||||
|
|
||||||
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
|
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
|
||||||
/// values, with one for each argument. This specifies whether the argument
|
/// values, with one for each argument. This specifies whether the argument
|
||||||
|
@ -65,11 +64,11 @@ public:
|
||||||
/// only support 10 ranges, could easily be extended if needed.
|
/// only support 10 ranges, could easily be extended if needed.
|
||||||
SourceRange DiagRanges[10];
|
SourceRange DiagRanges[10];
|
||||||
|
|
||||||
enum { MaxCodeModificationHints = 3 };
|
enum { MaxFixItHints = 3 };
|
||||||
|
|
||||||
/// CodeModificationHints - If valid, provides a hint with some code
|
/// FixItHints - If valid, provides a hint with some code
|
||||||
/// to insert, remove, or modify at a particular position.
|
/// to insert, remove, or modify at a particular position.
|
||||||
CodeModificationHint CodeModificationHints[MaxCodeModificationHints];
|
FixItHint FixItHints[MaxFixItHints];
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief An allocator for Storage objects, which uses a small cache to
|
/// \brief An allocator for Storage objects, which uses a small cache to
|
||||||
|
@ -92,7 +91,7 @@ public:
|
||||||
Storage *Result = FreeList[--NumFreeListEntries];
|
Storage *Result = FreeList[--NumFreeListEntries];
|
||||||
Result->NumDiagArgs = 0;
|
Result->NumDiagArgs = 0;
|
||||||
Result->NumDiagRanges = 0;
|
Result->NumDiagRanges = 0;
|
||||||
Result->NumCodeModificationHints = 0;
|
Result->NumFixItHints = 0;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,17 +165,16 @@ private:
|
||||||
DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R;
|
DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCodeModificationHint(const CodeModificationHint &Hint) const {
|
void AddFixItHint(const FixItHint &Hint) const {
|
||||||
if (Hint.isNull())
|
if (Hint.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!DiagStorage)
|
if (!DiagStorage)
|
||||||
DiagStorage = getStorage();
|
DiagStorage = getStorage();
|
||||||
|
|
||||||
assert(DiagStorage->NumCodeModificationHints <
|
assert(DiagStorage->NumFixItHints < Storage::MaxFixItHints &&
|
||||||
Storage::MaxCodeModificationHints &&
|
|
||||||
"Too many code modification hints!");
|
"Too many code modification hints!");
|
||||||
DiagStorage->CodeModificationHints[DiagStorage->NumCodeModificationHints++]
|
DiagStorage->FixItHints[DiagStorage->NumFixItHints++]
|
||||||
= Hint;
|
= Hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +234,8 @@ public:
|
||||||
DB.AddSourceRange(DiagStorage->DiagRanges[i]);
|
DB.AddSourceRange(DiagStorage->DiagRanges[i]);
|
||||||
|
|
||||||
// Add all code modification hints
|
// Add all code modification hints
|
||||||
for (unsigned i = 0, e = DiagStorage->NumCodeModificationHints; i != e; ++i)
|
for (unsigned i = 0, e = DiagStorage->NumFixItHints; i != e; ++i)
|
||||||
DB.AddCodeModificationHint(DiagStorage->CodeModificationHints[i]);
|
DB.AddFixItHint(DiagStorage->FixItHints[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Clear out this partial diagnostic, giving it a new diagnostic ID
|
/// \brief Clear out this partial diagnostic, giving it a new diagnostic ID
|
||||||
|
@ -284,8 +282,8 @@ public:
|
||||||
DeclarationName N);
|
DeclarationName N);
|
||||||
|
|
||||||
friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
|
friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
|
||||||
const CodeModificationHint &Hint) {
|
const FixItHint &Hint) {
|
||||||
PD.AddCodeModificationHint(Hint);
|
PD.AddFixItHint(Hint);
|
||||||
return PD;
|
return PD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string str;
|
const std::string str;
|
||||||
std::vector<CodeModificationHint> CodeModificationHints;
|
std::vector<FixItHint> FixItHints;
|
||||||
const Kind kind;
|
const Kind kind;
|
||||||
const DisplayHint Hint;
|
const DisplayHint Hint;
|
||||||
std::vector<SourceRange> ranges;
|
std::vector<SourceRange> ranges;
|
||||||
|
@ -203,8 +203,8 @@ public:
|
||||||
ranges.push_back(SourceRange(B,E));
|
ranges.push_back(SourceRange(B,E));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addCodeModificationHint(const CodeModificationHint& Hint) {
|
void addFixItHint(const FixItHint& Hint) {
|
||||||
CodeModificationHints.push_back(Hint);
|
FixItHints.push_back(Hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef const SourceRange* range_iterator;
|
typedef const SourceRange* range_iterator;
|
||||||
|
@ -217,15 +217,15 @@ public:
|
||||||
return ranges_begin() + ranges.size();
|
return ranges_begin() + ranges.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef const CodeModificationHint *code_modifications_iterator;
|
typedef const FixItHint *fixit_iterator;
|
||||||
|
|
||||||
code_modifications_iterator code_modifications_begin() const {
|
fixit_iterator fixit_begin() const {
|
||||||
return CodeModificationHints.empty()? 0 : &CodeModificationHints[0];
|
return FixItHints.empty()? 0 : &FixItHints[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
code_modifications_iterator code_modifications_end() const {
|
fixit_iterator fixit_end() const {
|
||||||
return CodeModificationHints.empty()? 0
|
return FixItHints.empty()? 0
|
||||||
: &CodeModificationHints[0] + CodeModificationHints.size();
|
: &FixItHints[0] + FixItHints.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool classof(const PathDiagnosticPiece* P) {
|
static inline bool classof(const PathDiagnosticPiece* P) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
void EmitCaretDiagnostic(SourceLocation Loc,
|
void EmitCaretDiagnostic(SourceLocation Loc,
|
||||||
SourceRange *Ranges, unsigned NumRanges,
|
SourceRange *Ranges, unsigned NumRanges,
|
||||||
SourceManager &SM,
|
SourceManager &SM,
|
||||||
const CodeModificationHint *Hints,
|
const FixItHint *Hints,
|
||||||
unsigned NumHints,
|
unsigned NumHints,
|
||||||
unsigned Columns);
|
unsigned Columns);
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,7 @@ bool DiagnosticBuilder::Emit() {
|
||||||
// the Diagnostic object.
|
// the Diagnostic object.
|
||||||
DiagObj->NumDiagArgs = NumArgs;
|
DiagObj->NumDiagArgs = NumArgs;
|
||||||
DiagObj->NumDiagRanges = NumRanges;
|
DiagObj->NumDiagRanges = NumRanges;
|
||||||
DiagObj->NumCodeModificationHints = NumCodeModificationHints;
|
DiagObj->NumFixItHints = NumFixItHints;
|
||||||
|
|
||||||
// Process the diagnostic, sending the accumulated information to the
|
// Process the diagnostic, sending the accumulated information to the
|
||||||
// DiagnosticClient.
|
// DiagnosticClient.
|
||||||
|
@ -996,9 +996,9 @@ StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level,
|
||||||
for (unsigned I = 0, N = Info.getNumRanges(); I != N; ++I)
|
for (unsigned I = 0, N = Info.getNumRanges(); I != N; ++I)
|
||||||
Ranges.push_back(Info.getRange(I));
|
Ranges.push_back(Info.getRange(I));
|
||||||
|
|
||||||
FixIts.reserve(Info.getNumCodeModificationHints());
|
FixIts.reserve(Info.getNumFixItHints());
|
||||||
for (unsigned I = 0, N = Info.getNumCodeModificationHints(); I != N; ++I)
|
for (unsigned I = 0, N = Info.getNumFixItHints(); I != N; ++I)
|
||||||
FixIts.push_back(Info.getCodeModificationHint(I));
|
FixIts.push_back(Info.getFixItHint(I));
|
||||||
}
|
}
|
||||||
|
|
||||||
StoredDiagnostic::~StoredDiagnostic() { }
|
StoredDiagnostic::~StoredDiagnostic() { }
|
||||||
|
@ -1231,7 +1231,7 @@ StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM,
|
||||||
return Diag;
|
return Diag;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeModificationHint Hint;
|
FixItHint Hint;
|
||||||
Hint.RemoveRange = SourceRange(RemoveBegin, RemoveEnd);
|
Hint.RemoveRange = SourceRange(RemoveBegin, RemoveEnd);
|
||||||
Hint.InsertionLoc = InsertionLoc;
|
Hint.InsertionLoc = InsertionLoc;
|
||||||
Hint.CodeToInsert.assign(Memory, Memory + InsertLen);
|
Hint.CodeToInsert.assign(Memory, Memory + InsertLen);
|
||||||
|
|
|
@ -108,8 +108,8 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||||
|
|
||||||
for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
|
for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
|
||||||
P->addRange(Info.getRange(i));
|
P->addRange(Info.getRange(i));
|
||||||
for (unsigned i = 0, e = Info.getNumCodeModificationHints(); i != e; ++i)
|
for (unsigned i = 0, e = Info.getNumFixItHints(); i != e; ++i)
|
||||||
P->addCodeModificationHint(Info.getCodeModificationHint(i));
|
P->addFixItHint(Info.getFixItHint(i));
|
||||||
D->push_front(P);
|
D->push_front(P);
|
||||||
|
|
||||||
HandlePathDiagnostic(D);
|
HandlePathDiagnostic(D);
|
||||||
|
|
|
@ -93,7 +93,7 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||||
// completely ignore it, even if it's an error: fix-it locations
|
// completely ignore it, even if it's an error: fix-it locations
|
||||||
// are meant to perform specific fix-ups even in the presence of
|
// are meant to perform specific fix-ups even in the presence of
|
||||||
// other errors.
|
// other errors.
|
||||||
if (Info.getNumCodeModificationHints() == 0)
|
if (Info.getNumFixItHints() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// See if the location of the error is one that matches what the
|
// See if the location of the error is one that matches what the
|
||||||
|
@ -122,10 +122,10 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||||
|
|
||||||
// Make sure that we can perform all of the modifications we
|
// Make sure that we can perform all of the modifications we
|
||||||
// in this diagnostic.
|
// in this diagnostic.
|
||||||
bool CanRewrite = Info.getNumCodeModificationHints() > 0;
|
bool CanRewrite = Info.getNumFixItHints() > 0;
|
||||||
for (unsigned Idx = 0, Last = Info.getNumCodeModificationHints();
|
for (unsigned Idx = 0, Last = Info.getNumFixItHints();
|
||||||
Idx < Last; ++Idx) {
|
Idx < Last; ++Idx) {
|
||||||
const CodeModificationHint &Hint = Info.getCodeModificationHint(Idx);
|
const FixItHint &Hint = Info.getFixItHint(Idx);
|
||||||
if (Hint.RemoveRange.isValid() &&
|
if (Hint.RemoveRange.isValid() &&
|
||||||
Rewrite.getRangeSize(Hint.RemoveRange) == -1) {
|
Rewrite.getRangeSize(Hint.RemoveRange) == -1) {
|
||||||
CanRewrite = false;
|
CanRewrite = false;
|
||||||
|
@ -140,7 +140,7 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CanRewrite) {
|
if (!CanRewrite) {
|
||||||
if (Info.getNumCodeModificationHints() > 0)
|
if (Info.getNumFixItHints() > 0)
|
||||||
Diag(Info.getLocation(), diag::note_fixit_in_macro);
|
Diag(Info.getLocation(), diag::note_fixit_in_macro);
|
||||||
|
|
||||||
// If this was an error, refuse to perform any rewriting.
|
// If this was an error, refuse to perform any rewriting.
|
||||||
|
@ -152,9 +152,9 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Failed = false;
|
bool Failed = false;
|
||||||
for (unsigned Idx = 0, Last = Info.getNumCodeModificationHints();
|
for (unsigned Idx = 0, Last = Info.getNumFixItHints();
|
||||||
Idx < Last; ++Idx) {
|
Idx < Last; ++Idx) {
|
||||||
const CodeModificationHint &Hint = Info.getCodeModificationHint(Idx);
|
const FixItHint &Hint = Info.getFixItHint(Idx);
|
||||||
if (!Hint.RemoveRange.isValid()) {
|
if (!Hint.RemoveRange.isValid()) {
|
||||||
// We're adding code.
|
// We're adding code.
|
||||||
if (Rewrite.InsertTextBefore(Hint.InsertionLoc, Hint.CodeToInsert))
|
if (Rewrite.InsertTextBefore(Hint.InsertionLoc, Hint.CodeToInsert))
|
||||||
|
|
|
@ -484,8 +484,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
|
||||||
// FIXME: This code is disabled because it seems to mangle the HTML
|
// FIXME: This code is disabled because it seems to mangle the HTML
|
||||||
// output. I'm leaving it here because it's generally the right idea,
|
// output. I'm leaving it here because it's generally the right idea,
|
||||||
// but needs some help from someone more familiar with the rewriter.
|
// but needs some help from someone more familiar with the rewriter.
|
||||||
for (const CodeModificationHint *Hint = P.code_modifications_begin(),
|
for (const FixItHint *Hint = P.fixit_begin(), *HintEnd = P.fixit_end();
|
||||||
*HintEnd = P.code_modifications_end();
|
|
||||||
Hint != HintEnd; ++Hint) {
|
Hint != HintEnd; ++Hint) {
|
||||||
if (Hint->RemoveRange.isValid()) {
|
if (Hint->RemoveRange.isValid()) {
|
||||||
HighlightRange(R, LPosInfo.first, Hint->RemoveRange,
|
HighlightRange(R, LPosInfo.first, Hint->RemoveRange,
|
||||||
|
|
|
@ -276,7 +276,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
|
||||||
SourceRange *Ranges,
|
SourceRange *Ranges,
|
||||||
unsigned NumRanges,
|
unsigned NumRanges,
|
||||||
SourceManager &SM,
|
SourceManager &SM,
|
||||||
const CodeModificationHint *Hints,
|
const FixItHint *Hints,
|
||||||
unsigned NumHints,
|
unsigned NumHints,
|
||||||
unsigned Columns) {
|
unsigned Columns) {
|
||||||
assert(LangOpts && "Unexpected diagnostic outside source file processing");
|
assert(LangOpts && "Unexpected diagnostic outside source file processing");
|
||||||
|
@ -409,7 +409,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
|
||||||
|
|
||||||
std::string FixItInsertionLine;
|
std::string FixItInsertionLine;
|
||||||
if (NumHints && DiagOpts->ShowFixits) {
|
if (NumHints && DiagOpts->ShowFixits) {
|
||||||
for (const CodeModificationHint *Hint = Hints, *LastHint = Hints + NumHints;
|
for (const FixItHint *Hint = Hints, *LastHint = Hints + NumHints;
|
||||||
Hint != LastHint; ++Hint) {
|
Hint != LastHint; ++Hint) {
|
||||||
if (Hint->InsertionLoc.isValid()) {
|
if (Hint->InsertionLoc.isValid()) {
|
||||||
// We have an insertion hint. Determine whether the inserted
|
// We have an insertion hint. Determine whether the inserted
|
||||||
|
@ -833,7 +833,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
|
||||||
if (DiagOpts->ShowCarets && Info.getLocation().isValid() &&
|
if (DiagOpts->ShowCarets && Info.getLocation().isValid() &&
|
||||||
((LastLoc != Info.getLocation()) || Info.getNumRanges() ||
|
((LastLoc != Info.getLocation()) || Info.getNumRanges() ||
|
||||||
(LastCaretDiagnosticWasNote && Level != Diagnostic::Note) ||
|
(LastCaretDiagnosticWasNote && Level != Diagnostic::Note) ||
|
||||||
Info.getNumCodeModificationHints())) {
|
Info.getNumFixItHints())) {
|
||||||
// Cache the LastLoc, it allows us to omit duplicate source/caret spewage.
|
// Cache the LastLoc, it allows us to omit duplicate source/caret spewage.
|
||||||
LastLoc = Info.getLocation();
|
LastLoc = Info.getLocation();
|
||||||
LastCaretDiagnosticWasNote = (Level == Diagnostic::Note);
|
LastCaretDiagnosticWasNote = (Level == Diagnostic::Note);
|
||||||
|
@ -845,9 +845,9 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
|
||||||
for (unsigned i = 0; i != NumRanges; ++i)
|
for (unsigned i = 0; i != NumRanges; ++i)
|
||||||
Ranges[i] = Info.getRange(i);
|
Ranges[i] = Info.getRange(i);
|
||||||
|
|
||||||
unsigned NumHints = Info.getNumCodeModificationHints();
|
unsigned NumHints = Info.getNumFixItHints();
|
||||||
for (unsigned idx = 0; idx < NumHints; ++idx) {
|
for (unsigned idx = 0; idx < NumHints; ++idx) {
|
||||||
const CodeModificationHint &Hint = Info.getCodeModificationHint(idx);
|
const FixItHint &Hint = Info.getFixItHint(idx);
|
||||||
if (Hint.RemoveRange.isValid()) {
|
if (Hint.RemoveRange.isValid()) {
|
||||||
assert(NumRanges < 20 && "Out of space");
|
assert(NumRanges < 20 && "Out of space");
|
||||||
Ranges[NumRanges++] = Hint.RemoveRange;
|
Ranges[NumRanges++] = Hint.RemoveRange;
|
||||||
|
@ -855,8 +855,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
|
||||||
}
|
}
|
||||||
|
|
||||||
EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager(),
|
EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager(),
|
||||||
Info.getCodeModificationHints(),
|
Info.getFixItHints(),
|
||||||
Info.getNumCodeModificationHints(),
|
Info.getNumFixItHints(),
|
||||||
DiagOpts->MessageLength);
|
DiagOpts->MessageLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1372,8 +1372,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
|
||||||
// a pedwarn.
|
// a pedwarn.
|
||||||
if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
|
if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
|
||||||
Diag(BufferEnd, diag::ext_no_newline_eof)
|
Diag(BufferEnd, diag::ext_no_newline_eof)
|
||||||
<< CodeModificationHint::CreateInsertion(getSourceLocation(BufferEnd),
|
<< FixItHint::CreateInsertion(getSourceLocation(BufferEnd), "\n");
|
||||||
"\n");
|
|
||||||
|
|
||||||
BufferPtr = CurPtr;
|
BufferPtr = CurPtr;
|
||||||
|
|
||||||
|
|
|
@ -127,10 +127,10 @@ void Preprocessor::CheckEndOfDirective(const char *DirType, bool EnableMacros) {
|
||||||
// Add a fixit in GNU/C99/C++ mode. Don't offer a fixit for strict-C89,
|
// Add a fixit in GNU/C99/C++ mode. Don't offer a fixit for strict-C89,
|
||||||
// because it is more trouble than it is worth to insert /**/ and check that
|
// because it is more trouble than it is worth to insert /**/ and check that
|
||||||
// there is no /**/ in the range also.
|
// there is no /**/ in the range also.
|
||||||
CodeModificationHint FixItHint;
|
FixItHint Hint;
|
||||||
if (Features.GNUMode || Features.C99 || Features.CPlusPlus)
|
if (Features.GNUMode || Features.C99 || Features.CPlusPlus)
|
||||||
FixItHint = CodeModificationHint::CreateInsertion(Tmp.getLocation(),"//");
|
Hint = FixItHint::CreateInsertion(Tmp.getLocation(),"//");
|
||||||
Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType << FixItHint;
|
Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType << Hint;
|
||||||
DiscardUntilEndOfDirective();
|
DiscardUntilEndOfDirective();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,7 +481,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
|
||||||
if (TypeSpecComplex != TSC_unspecified) {
|
if (TypeSpecComplex != TSC_unspecified) {
|
||||||
if (TypeSpecType == TST_unspecified) {
|
if (TypeSpecType == TST_unspecified) {
|
||||||
Diag(D, TSCLoc, SrcMgr, diag::ext_plain_complex)
|
Diag(D, TSCLoc, SrcMgr, diag::ext_plain_complex)
|
||||||
<< CodeModificationHint::CreateInsertion(
|
<< FixItHint::CreateInsertion(
|
||||||
PP.getLocForEndOfToken(getTypeSpecComplexLoc()),
|
PP.getLocForEndOfToken(getTypeSpecComplexLoc()),
|
||||||
" double");
|
" double");
|
||||||
TypeSpecType = TST_double; // _Complex -> _Complex double.
|
TypeSpecType = TST_double; // _Complex -> _Complex double.
|
||||||
|
@ -507,7 +507,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
|
||||||
|
|
||||||
Diag(D, SCLoc, SrcMgr, diag::err_friend_storage_spec)
|
Diag(D, SCLoc, SrcMgr, diag::err_friend_storage_spec)
|
||||||
<< SpecName
|
<< SpecName
|
||||||
<< CodeModificationHint::CreateRemoval(SourceRange(SCLoc, SCEndLoc));
|
<< FixItHint::CreateRemoval(SourceRange(SCLoc, SCEndLoc));
|
||||||
|
|
||||||
ClearStorageClassSpecs();
|
ClearStorageClassSpecs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,7 +734,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
|
||||||
if (TagName) {
|
if (TagName) {
|
||||||
Diag(Loc, diag::err_use_of_tag_name_without_tag)
|
Diag(Loc, diag::err_use_of_tag_name_without_tag)
|
||||||
<< Tok.getIdentifierInfo() << TagName << getLang().CPlusPlus
|
<< Tok.getIdentifierInfo() << TagName << getLang().CPlusPlus
|
||||||
<< CodeModificationHint::CreateInsertion(Tok.getLocation(),TagName);
|
<< FixItHint::CreateInsertion(Tok.getLocation(),TagName);
|
||||||
|
|
||||||
// Parse this as a tag as if the missing tag were present.
|
// Parse this as a tag as if the missing tag were present.
|
||||||
if (TagKind == tok::kw_enum)
|
if (TagKind == tok::kw_enum)
|
||||||
|
@ -1360,7 +1360,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
||||||
DS.SetRangeEnd(EndProtoLoc);
|
DS.SetRangeEnd(EndProtoLoc);
|
||||||
|
|
||||||
Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
|
Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
|
||||||
<< CodeModificationHint::CreateInsertion(Loc, "id")
|
<< FixItHint::CreateInsertion(Loc, "id")
|
||||||
<< SourceRange(Loc, EndProtoLoc);
|
<< SourceRange(Loc, EndProtoLoc);
|
||||||
// Need to support trailing type qualifiers (e.g. "id<p> const").
|
// Need to support trailing type qualifiers (e.g. "id<p> const").
|
||||||
// If a type specifier follows, it will be diagnosed elsewhere.
|
// If a type specifier follows, it will be diagnosed elsewhere.
|
||||||
|
@ -1756,7 +1756,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
|
||||||
// Check for extraneous top-level semicolon.
|
// Check for extraneous top-level semicolon.
|
||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
Diag(Tok, diag::ext_extra_struct_semi)
|
Diag(Tok, diag::ext_extra_struct_semi)
|
||||||
<< CodeModificationHint::CreateRemoval(Tok.getLocation());
|
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +1999,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
|
||||||
!(getLang().C99 || getLang().CPlusPlus0x))
|
!(getLang().C99 || getLang().CPlusPlus0x))
|
||||||
Diag(CommaLoc, diag::ext_enumerator_list_comma)
|
Diag(CommaLoc, diag::ext_enumerator_list_comma)
|
||||||
<< getLang().CPlusPlus
|
<< getLang().CPlusPlus
|
||||||
<< CodeModificationHint::CreateRemoval(CommaLoc);
|
<< FixItHint::CreateRemoval(CommaLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eat the }.
|
// Eat the }.
|
||||||
|
@ -3009,7 +3009,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
// We have ellipsis without a preceding ',', which is ill-formed
|
// We have ellipsis without a preceding ',', which is ill-formed
|
||||||
// in C. Complain and provide the fix.
|
// in C. Complain and provide the fix.
|
||||||
Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
|
Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
|
||||||
<< CodeModificationHint::CreateInsertion(EllipsisLoc, ", ");
|
<< FixItHint::CreateInsertion(EllipsisLoc, ", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -837,7 +837,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
||||||
Diag(TemplateId->TemplateNameLoc,
|
Diag(TemplateId->TemplateNameLoc,
|
||||||
diag::err_explicit_instantiation_with_definition)
|
diag::err_explicit_instantiation_with_definition)
|
||||||
<< SourceRange(TemplateInfo.TemplateLoc)
|
<< SourceRange(TemplateInfo.TemplateLoc)
|
||||||
<< CodeModificationHint::CreateInsertion(LAngleLoc, "<>");
|
<< FixItHint::CreateInsertion(LAngleLoc, "<>");
|
||||||
|
|
||||||
// Create a fake template parameter list that contains only
|
// Create a fake template parameter list that contains only
|
||||||
// "template<>", so that we treat this construct as a class
|
// "template<>", so that we treat this construct as a class
|
||||||
|
@ -1079,7 +1079,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) {
|
||||||
if (IsVirtual) {
|
if (IsVirtual) {
|
||||||
// Complain about duplicate 'virtual'
|
// Complain about duplicate 'virtual'
|
||||||
Diag(VirtualLoc, diag::err_dup_virtual)
|
Diag(VirtualLoc, diag::err_dup_virtual)
|
||||||
<< CodeModificationHint::CreateRemoval(VirtualLoc);
|
<< FixItHint::CreateRemoval(VirtualLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsVirtual = true;
|
IsVirtual = true;
|
||||||
|
@ -1554,7 +1554,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
|
||||||
// Check for extraneous top-level semicolon.
|
// Check for extraneous top-level semicolon.
|
||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
Diag(Tok, diag::ext_extra_struct_semi)
|
Diag(Tok, diag::ext_extra_struct_semi)
|
||||||
<< CodeModificationHint::CreateRemoval(Tok.getLocation());
|
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
|
||||||
// recover like this.
|
// recover like this.
|
||||||
PP.LookAhead(1).is(tok::identifier)) {
|
PP.LookAhead(1).is(tok::identifier)) {
|
||||||
Diag(Next, diag::err_unexected_colon_in_nested_name_spec)
|
Diag(Next, diag::err_unexected_colon_in_nested_name_spec)
|
||||||
<< CodeModificationHint::CreateReplacement(Next.getLocation(), "::");
|
<< FixItHint::CreateReplacement(Next.getLocation(), "::");
|
||||||
|
|
||||||
// Recover as if the user wrote '::'.
|
// Recover as if the user wrote '::'.
|
||||||
Next.setKind(tok::coloncolon);
|
Next.setKind(tok::coloncolon);
|
||||||
|
@ -1313,7 +1313,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
|
||||||
Diag(TemplateId->TemplateNameLoc,
|
Diag(TemplateId->TemplateNameLoc,
|
||||||
diag::err_out_of_line_constructor_template_id)
|
diag::err_out_of_line_constructor_template_id)
|
||||||
<< TemplateId->Name
|
<< TemplateId->Name
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(
|
||||||
SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc));
|
SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc));
|
||||||
Result.setConstructorName(Actions.getTypeName(*TemplateId->Name,
|
Result.setConstructorName(Actions.getTypeName(*TemplateId->Name,
|
||||||
TemplateId->TemplateNameLoc,
|
TemplateId->TemplateNameLoc,
|
||||||
|
|
|
@ -76,9 +76,8 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
|
||||||
SourceLocation ColonLoc = ConsumeToken();
|
SourceLocation ColonLoc = ConsumeToken();
|
||||||
|
|
||||||
Diag(Tok, diag::ext_gnu_old_style_field_designator)
|
Diag(Tok, diag::ext_gnu_old_style_field_designator)
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(NameLoc,
|
<< FixItHint::CreateReplacement(SourceRange(NameLoc, ColonLoc),
|
||||||
ColonLoc),
|
NewSyntax.str());
|
||||||
NewSyntax.str());
|
|
||||||
|
|
||||||
Designation D;
|
Designation D;
|
||||||
D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc));
|
D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc));
|
||||||
|
@ -218,7 +217,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
|
||||||
(Desig.getDesignator(0).isArrayDesignator() ||
|
(Desig.getDesignator(0).isArrayDesignator() ||
|
||||||
Desig.getDesignator(0).isArrayRangeDesignator())) {
|
Desig.getDesignator(0).isArrayRangeDesignator())) {
|
||||||
Diag(Tok, diag::ext_gnu_missing_equal_designator)
|
Diag(Tok, diag::ext_gnu_missing_equal_designator)
|
||||||
<< CodeModificationHint::CreateInsertion(Tok.getLocation(), "= ");
|
<< FixItHint::CreateInsertion(Tok.getLocation(), "= ");
|
||||||
return Actions.ActOnDesignatedInitializer(Desig, Tok.getLocation(),
|
return Actions.ActOnDesignatedInitializer(Desig, Tok.getLocation(),
|
||||||
true, ParseInitializer());
|
true, ParseInitializer());
|
||||||
}
|
}
|
||||||
|
|
|
@ -988,7 +988,7 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
|
||||||
// Check for extraneous top-level semicolon.
|
// Check for extraneous top-level semicolon.
|
||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
Diag(Tok, diag::ext_extra_struct_semi)
|
Diag(Tok, diag::ext_extra_struct_semi)
|
||||||
<< CodeModificationHint::CreateRemoval(Tok.getLocation());
|
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1571,7 +1571,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
|
||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
if (ObjCImpDecl) {
|
if (ObjCImpDecl) {
|
||||||
Diag(Tok, diag::warn_semicolon_before_method_body)
|
Diag(Tok, diag::warn_semicolon_before_method_body)
|
||||||
<< CodeModificationHint::CreateRemoval(Tok.getLocation());
|
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||||
}
|
}
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,7 +660,7 @@ Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
|
||||||
ReplaceStr = "> > ";
|
ReplaceStr = "> > ";
|
||||||
|
|
||||||
Diag(Tok.getLocation(), diag::err_two_right_angle_brackets_need_space)
|
Diag(Tok.getLocation(), diag::err_two_right_angle_brackets_need_space)
|
||||||
<< CodeModificationHint::CreateReplacement(
|
<< FixItHint::CreateReplacement(
|
||||||
SourceRange(Tok.getLocation()), ReplaceStr);
|
SourceRange(Tok.getLocation()), ReplaceStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ void Parser::SuggestParentheses(SourceLocation Loc, unsigned DK,
|
||||||
}
|
}
|
||||||
|
|
||||||
Diag(Loc, DK)
|
Diag(Loc, DK)
|
||||||
<< CodeModificationHint::CreateInsertion(ParenRange.getBegin(), "(")
|
<< FixItHint::CreateInsertion(ParenRange.getBegin(), "(")
|
||||||
<< CodeModificationHint::CreateInsertion(EndLoc, ")");
|
<< FixItHint::CreateInsertion(EndLoc, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
|
/// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
|
||||||
|
@ -146,7 +146,7 @@ bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
|
||||||
// Show what code to insert to fix this problem.
|
// Show what code to insert to fix this problem.
|
||||||
Diag(EndLoc, DiagID)
|
Diag(EndLoc, DiagID)
|
||||||
<< Msg
|
<< Msg
|
||||||
<< CodeModificationHint::CreateInsertion(EndLoc, Spelling);
|
<< FixItHint::CreateInsertion(EndLoc, Spelling);
|
||||||
} else
|
} else
|
||||||
Diag(Tok, DiagID) << Msg;
|
Diag(Tok, DiagID) << Msg;
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr)
|
||||||
case tok::semi:
|
case tok::semi:
|
||||||
if (!getLang().CPlusPlus0x)
|
if (!getLang().CPlusPlus0x)
|
||||||
Diag(Tok, diag::ext_top_level_semi)
|
Diag(Tok, diag::ext_top_level_semi)
|
||||||
<< CodeModificationHint::CreateRemoval(Tok.getLocation());
|
<< FixItHint::CreateRemoval(Tok.getLocation());
|
||||||
|
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
// TODO: Invoke action for top-level semicolon.
|
// TODO: Invoke action for top-level semicolon.
|
||||||
|
@ -829,7 +829,7 @@ Parser::OwningExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
|
||||||
PP.getLocForEndOfToken(Tok.getLocation()));
|
PP.getLocForEndOfToken(Tok.getLocation()));
|
||||||
|
|
||||||
Diag(Tok, diag::warn_file_asm_volatile)
|
Diag(Tok, diag::warn_file_asm_volatile)
|
||||||
<< CodeModificationHint::CreateRemoval(RemovalRange);
|
<< FixItHint::CreateRemoval(RemovalRange);
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,13 +486,13 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
|
||||||
if (LookupCtx)
|
if (LookupCtx)
|
||||||
Diag(Found.getNameLoc(), diag::err_no_member_suggest)
|
Diag(Found.getNameLoc(), diag::err_no_member_suggest)
|
||||||
<< Name << LookupCtx << Found.getLookupName() << SS.getRange()
|
<< Name << LookupCtx << Found.getLookupName() << SS.getRange()
|
||||||
<< CodeModificationHint::CreateReplacement(Found.getNameLoc(),
|
<< FixItHint::CreateReplacement(Found.getNameLoc(),
|
||||||
Found.getLookupName().getAsString());
|
Found.getLookupName().getAsString());
|
||||||
else
|
else
|
||||||
Diag(Found.getNameLoc(), diag::err_undeclared_var_use_suggest)
|
Diag(Found.getNameLoc(), diag::err_undeclared_var_use_suggest)
|
||||||
<< Name << Found.getLookupName()
|
<< Name << Found.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(Found.getNameLoc(),
|
<< FixItHint::CreateReplacement(Found.getNameLoc(),
|
||||||
Found.getLookupName().getAsString());
|
Found.getLookupName().getAsString());
|
||||||
|
|
||||||
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
|
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
|
||||||
Diag(ND->getLocation(), diag::note_previous_decl)
|
Diag(ND->getLocation(), diag::note_previous_decl)
|
||||||
|
|
|
@ -255,13 +255,13 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,
|
||||||
if (!SS || !SS->isSet())
|
if (!SS || !SS->isSet())
|
||||||
Diag(IILoc, diag::err_unknown_typename_suggest)
|
Diag(IILoc, diag::err_unknown_typename_suggest)
|
||||||
<< &II << Lookup.getLookupName()
|
<< &II << Lookup.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(IILoc),
|
<< FixItHint::CreateReplacement(SourceRange(IILoc),
|
||||||
Result->getNameAsString());
|
Result->getNameAsString());
|
||||||
else if (DeclContext *DC = computeDeclContext(*SS, false))
|
else if (DeclContext *DC = computeDeclContext(*SS, false))
|
||||||
Diag(IILoc, diag::err_unknown_nested_typename_suggest)
|
Diag(IILoc, diag::err_unknown_nested_typename_suggest)
|
||||||
<< &II << DC << Lookup.getLookupName() << SS->getRange()
|
<< &II << DC << Lookup.getLookupName() << SS->getRange()
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(IILoc),
|
<< FixItHint::CreateReplacement(SourceRange(IILoc),
|
||||||
Result->getNameAsString());
|
Result->getNameAsString());
|
||||||
else
|
else
|
||||||
llvm_unreachable("could not have corrected a typo here");
|
llvm_unreachable("could not have corrected a typo here");
|
||||||
|
|
||||||
|
@ -285,8 +285,7 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,
|
||||||
Diag(SS->getRange().getBegin(), diag::err_typename_missing)
|
Diag(SS->getRange().getBegin(), diag::err_typename_missing)
|
||||||
<< (NestedNameSpecifier *)SS->getScopeRep() << II.getName()
|
<< (NestedNameSpecifier *)SS->getScopeRep() << II.getName()
|
||||||
<< SourceRange(SS->getRange().getBegin(), IILoc)
|
<< SourceRange(SS->getRange().getBegin(), IILoc)
|
||||||
<< CodeModificationHint::CreateInsertion(SS->getRange().getBegin(),
|
<< FixItHint::CreateInsertion(SS->getRange().getBegin(), "typename ");
|
||||||
"typename ");
|
|
||||||
SuggestedType = ActOnTypenameType(SourceLocation(), *SS, II, IILoc).get();
|
SuggestedType = ActOnTypenameType(SourceLocation(), *SS, II, IILoc).get();
|
||||||
} else {
|
} else {
|
||||||
assert(SS && SS->isInvalid() &&
|
assert(SS && SS->isInvalid() &&
|
||||||
|
@ -590,8 +589,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id,
|
||||||
(IDecl = R.getAsSingle<ObjCInterfaceDecl>())) {
|
(IDecl = R.getAsSingle<ObjCInterfaceDecl>())) {
|
||||||
Diag(RecoverLoc, diag::err_undef_interface_suggest)
|
Diag(RecoverLoc, diag::err_undef_interface_suggest)
|
||||||
<< Id << IDecl->getDeclName()
|
<< Id << IDecl->getDeclName()
|
||||||
<< CodeModificationHint::CreateReplacement(RecoverLoc,
|
<< FixItHint::CreateReplacement(RecoverLoc, IDecl->getNameAsString());
|
||||||
IDecl->getNameAsString());
|
|
||||||
Diag(IDecl->getLocation(), diag::note_previous_decl)
|
Diag(IDecl->getLocation(), diag::note_previous_decl)
|
||||||
<< IDecl->getDeclName();
|
<< IDecl->getDeclName();
|
||||||
|
|
||||||
|
@ -2345,8 +2343,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
if (SC == VarDecl::Static) {
|
if (SC == VarDecl::Static) {
|
||||||
Diag(D.getDeclSpec().getStorageClassSpecLoc(),
|
Diag(D.getDeclSpec().getStorageClassSpecLoc(),
|
||||||
diag::err_static_out_of_line)
|
diag::err_static_out_of_line)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
|
||||||
D.getDeclSpec().getStorageClassSpecLoc());
|
|
||||||
} else if (SC == VarDecl::None)
|
} else if (SC == VarDecl::None)
|
||||||
SC = VarDecl::Static;
|
SC = VarDecl::Static;
|
||||||
}
|
}
|
||||||
|
@ -2954,8 +2951,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
|
|
||||||
Diag(D.getIdentifierLoc(), diag::err_template_spec_decl_friend)
|
Diag(D.getIdentifierLoc(), diag::err_template_spec_decl_friend)
|
||||||
<< Name << RemoveRange
|
<< Name << RemoveRange
|
||||||
<< CodeModificationHint::CreateRemoval(RemoveRange)
|
<< FixItHint::CreateRemoval(RemoveRange)
|
||||||
<< CodeModificationHint::CreateInsertion(InsertLoc, "<>");
|
<< FixItHint::CreateInsertion(InsertLoc, "<>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2975,8 +2972,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
} else if (!CurContext->isRecord()) {
|
} else if (!CurContext->isRecord()) {
|
||||||
// 'virtual' was specified outside of the class.
|
// 'virtual' was specified outside of the class.
|
||||||
Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_out_of_class)
|
Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_out_of_class)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(D.getDeclSpec().getVirtualSpecLoc());
|
||||||
D.getDeclSpec().getVirtualSpecLoc());
|
|
||||||
} else {
|
} else {
|
||||||
// Okay: Add virtual to the method.
|
// Okay: Add virtual to the method.
|
||||||
CXXRecordDecl *CurClass = cast<CXXRecordDecl>(DC);
|
CXXRecordDecl *CurClass = cast<CXXRecordDecl>(DC);
|
||||||
|
@ -2993,16 +2989,14 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
// 'explicit' was specified outside of the class.
|
// 'explicit' was specified outside of the class.
|
||||||
Diag(D.getDeclSpec().getExplicitSpecLoc(),
|
Diag(D.getDeclSpec().getExplicitSpecLoc(),
|
||||||
diag::err_explicit_out_of_class)
|
diag::err_explicit_out_of_class)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(D.getDeclSpec().getExplicitSpecLoc());
|
||||||
D.getDeclSpec().getExplicitSpecLoc());
|
|
||||||
} else if (!isa<CXXConstructorDecl>(NewFD) &&
|
} else if (!isa<CXXConstructorDecl>(NewFD) &&
|
||||||
!isa<CXXConversionDecl>(NewFD)) {
|
!isa<CXXConversionDecl>(NewFD)) {
|
||||||
// 'explicit' was specified on a function that wasn't a constructor
|
// 'explicit' was specified on a function that wasn't a constructor
|
||||||
// or conversion function.
|
// or conversion function.
|
||||||
Diag(D.getDeclSpec().getExplicitSpecLoc(),
|
Diag(D.getDeclSpec().getExplicitSpecLoc(),
|
||||||
diag::err_explicit_non_ctor_or_conv_function)
|
diag::err_explicit_non_ctor_or_conv_function)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(D.getDeclSpec().getExplicitSpecLoc());
|
||||||
D.getDeclSpec().getExplicitSpecLoc());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3037,8 +3031,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
// member function definition.
|
// member function definition.
|
||||||
Diag(D.getDeclSpec().getStorageClassSpecLoc(),
|
Diag(D.getDeclSpec().getStorageClassSpecLoc(),
|
||||||
diag::err_static_out_of_line)
|
diag::err_static_out_of_line)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
|
||||||
D.getDeclSpec().getStorageClassSpecLoc());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle GNU asm-label extension (encoded as an attribute).
|
// Handle GNU asm-label extension (encoded as an attribute).
|
||||||
|
@ -3136,7 +3129,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
||||||
// too few of them).
|
// too few of them).
|
||||||
Diag(D.getIdentifierLoc(), diag::err_template_spec_needs_header)
|
Diag(D.getIdentifierLoc(), diag::err_template_spec_needs_header)
|
||||||
<< SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)
|
<< SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)
|
||||||
<< CodeModificationHint::CreateInsertion(
|
<< FixItHint::CreateInsertion(
|
||||||
D.getDeclSpec().getSourceRange().getBegin(),
|
D.getDeclSpec().getSourceRange().getBegin(),
|
||||||
"template<> ");
|
"template<> ");
|
||||||
isFunctionTemplateSpecialization = true;
|
isFunctionTemplateSpecialization = true;
|
||||||
|
@ -4174,7 +4167,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
|
||||||
<< ";\n";
|
<< ";\n";
|
||||||
Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
|
Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
|
||||||
<< FTI.ArgInfo[i].Ident
|
<< FTI.ArgInfo[i].Ident
|
||||||
<< CodeModificationHint::CreateInsertion(LocAfterDecls, Code.str());
|
<< FixItHint::CreateInsertion(LocAfterDecls, Code.str());
|
||||||
|
|
||||||
// Implicitly declare the argument as type 'int' for lack of a better
|
// Implicitly declare the argument as type 'int' for lack of a better
|
||||||
// type.
|
// type.
|
||||||
|
@ -4684,7 +4677,7 @@ bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
|
||||||
Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
|
Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
|
||||||
<< (NewTag == TagDecl::TK_class)
|
<< (NewTag == TagDecl::TK_class)
|
||||||
<< isTemplate << &Name
|
<< isTemplate << &Name
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(NewTagLoc),
|
<< FixItHint::CreateReplacement(SourceRange(NewTagLoc),
|
||||||
OldTag == TagDecl::TK_class? "class" : "struct");
|
OldTag == TagDecl::TK_class? "class" : "struct");
|
||||||
Diag(Previous->getLocation(), diag::note_previous_use);
|
Diag(Previous->getLocation(), diag::note_previous_use);
|
||||||
return true;
|
return true;
|
||||||
|
@ -4930,8 +4923,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
||||||
if (SafeToContinue)
|
if (SafeToContinue)
|
||||||
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
||||||
<< Name
|
<< Name
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(KWLoc),
|
<< FixItHint::CreateReplacement(SourceRange(KWLoc),
|
||||||
PrevTagDecl->getKindName());
|
PrevTagDecl->getKindName());
|
||||||
else
|
else
|
||||||
Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
|
Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
|
||||||
Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
|
Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
|
||||||
|
|
|
@ -1104,8 +1104,8 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
|
||||||
// member.
|
// member.
|
||||||
Diag(R.getNameLoc(), diag::err_mem_init_not_member_or_class_suggest)
|
Diag(R.getNameLoc(), diag::err_mem_init_not_member_or_class_suggest)
|
||||||
<< MemberOrBase << true << R.getLookupName()
|
<< MemberOrBase << true << R.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
Diag(Member->getLocation(), diag::note_previous_decl)
|
Diag(Member->getLocation(), diag::note_previous_decl)
|
||||||
<< Member->getDeclName();
|
<< Member->getDeclName();
|
||||||
|
|
||||||
|
@ -1123,8 +1123,8 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
|
||||||
// that base class.
|
// that base class.
|
||||||
Diag(R.getNameLoc(), diag::err_mem_init_not_member_or_class_suggest)
|
Diag(R.getNameLoc(), diag::err_mem_init_not_member_or_class_suggest)
|
||||||
<< MemberOrBase << false << R.getLookupName()
|
<< MemberOrBase << false << R.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
|
|
||||||
const CXXBaseSpecifier *BaseSpec = DirectBaseSpec? DirectBaseSpec
|
const CXXBaseSpecifier *BaseSpec = DirectBaseSpec? DirectBaseSpec
|
||||||
: VirtualBaseSpec;
|
: VirtualBaseSpec;
|
||||||
|
@ -2612,7 +2612,7 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
|
||||||
if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
|
if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
|
||||||
SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
|
SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
|
||||||
Diag(ParamLoc, diag::err_constructor_byvalue_arg)
|
Diag(ParamLoc, diag::err_constructor_byvalue_arg)
|
||||||
<< CodeModificationHint::CreateInsertion(ParamLoc, " const &");
|
<< FixItHint::CreateInsertion(ParamLoc, " const &");
|
||||||
|
|
||||||
// FIXME: Rather that making the constructor invalid, we should endeavor
|
// FIXME: Rather that making the constructor invalid, we should endeavor
|
||||||
// to fix the type.
|
// to fix the type.
|
||||||
|
@ -3157,8 +3157,7 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
|
||||||
UsingLoc = Name.getSourceRange().getBegin();
|
UsingLoc = Name.getSourceRange().getBegin();
|
||||||
|
|
||||||
Diag(UsingLoc, diag::warn_access_decl_deprecated)
|
Diag(UsingLoc, diag::warn_access_decl_deprecated)
|
||||||
<< CodeModificationHint::CreateInsertion(SS.getRange().getBegin(),
|
<< FixItHint::CreateInsertion(SS.getRange().getBegin(), "using ");
|
||||||
"using ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedDecl *UD = BuildUsingDeclaration(S, AS, UsingLoc, SS,
|
NamedDecl *UD = BuildUsingDeclaration(S, AS, UsingLoc, SS,
|
||||||
|
@ -5433,8 +5432,7 @@ Sema::DeclPtrTy Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
|
||||||
<< (unsigned) RD->getTagKind()
|
<< (unsigned) RD->getTagKind()
|
||||||
<< T
|
<< T
|
||||||
<< SourceRange(DS.getFriendSpecLoc())
|
<< SourceRange(DS.getFriendSpecLoc())
|
||||||
<< CodeModificationHint::CreateInsertion(DS.getTypeSpecTypeLoc(),
|
<< FixItHint::CreateInsertion(DS.getTypeSpecTypeLoc(), InsertionText);
|
||||||
InsertionText);
|
|
||||||
return DeclPtrTy();
|
return DeclPtrTy();
|
||||||
}else {
|
}else {
|
||||||
Diag(DS.getFriendSpecLoc(), diag::err_unexpected_friend)
|
Diag(DS.getFriendSpecLoc(), diag::err_unexpected_friend)
|
||||||
|
|
|
@ -559,8 +559,8 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
|
||||||
<< ClassName << R.getLookupName();
|
<< ClassName << R.getLookupName();
|
||||||
Diag(IDecl->getLocation(), diag::note_previous_decl)
|
Diag(IDecl->getLocation(), diag::note_previous_decl)
|
||||||
<< R.getLookupName()
|
<< R.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(ClassLoc,
|
<< FixItHint::CreateReplacement(ClassLoc,
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
IDecl = 0;
|
IDecl = 0;
|
||||||
} else {
|
} else {
|
||||||
Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
|
Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
|
||||||
|
|
|
@ -210,8 +210,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
|
||||||
// late-specified return types.
|
// late-specified return types.
|
||||||
Diag(New->getLocation(), diag::warn_missing_exception_specification)
|
Diag(New->getLocation(), diag::warn_missing_exception_specification)
|
||||||
<< New << OS.str()
|
<< New << OS.str()
|
||||||
<< CodeModificationHint::CreateInsertion(AfterParenLoc,
|
<< FixItHint::CreateInsertion(AfterParenLoc, " " + OS.str().str());
|
||||||
" " + OS.str().str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Old->getLocation().isInvalid())
|
if (!Old->getLocation().isInvalid())
|
||||||
|
|
|
@ -949,8 +949,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS,
|
||||||
// Actually quite difficult!
|
// Actually quite difficult!
|
||||||
if (isInstance)
|
if (isInstance)
|
||||||
Diag(R.getNameLoc(), diagnostic) << Name
|
Diag(R.getNameLoc(), diagnostic) << Name
|
||||||
<< CodeModificationHint::CreateInsertion(R.getNameLoc(),
|
<< FixItHint::CreateInsertion(R.getNameLoc(), "this->");
|
||||||
"this->");
|
|
||||||
else
|
else
|
||||||
Diag(R.getNameLoc(), diagnostic) << Name;
|
Diag(R.getNameLoc(), diagnostic) << Name;
|
||||||
|
|
||||||
|
@ -969,14 +968,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS,
|
||||||
if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) {
|
if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) {
|
||||||
if (SS.isEmpty())
|
if (SS.isEmpty())
|
||||||
Diag(R.getNameLoc(), diagnostic_suggest) << Name << R.getLookupName()
|
Diag(R.getNameLoc(), diagnostic_suggest) << Name << R.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
else
|
else
|
||||||
Diag(R.getNameLoc(), diag::err_no_member_suggest)
|
Diag(R.getNameLoc(), diag::err_no_member_suggest)
|
||||||
<< Name << computeDeclContext(SS, false) << R.getLookupName()
|
<< Name << computeDeclContext(SS, false) << R.getLookupName()
|
||||||
<< SS.getRange()
|
<< SS.getRange()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
|
if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
|
||||||
Diag(ND->getLocation(), diag::note_previous_decl)
|
Diag(ND->getLocation(), diag::note_previous_decl)
|
||||||
<< ND->getDeclName();
|
<< ND->getDeclName();
|
||||||
|
@ -2614,8 +2613,8 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
|
||||||
(isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin()))) {
|
(isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin()))) {
|
||||||
SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest)
|
SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest)
|
||||||
<< Name << DC << R.getLookupName() << SS.getRange()
|
<< Name << DC << R.getLookupName() << SS.getRange()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
|
if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
|
||||||
SemaRef.Diag(ND->getLocation(), diag::note_previous_decl)
|
SemaRef.Diag(ND->getLocation(), diag::note_previous_decl)
|
||||||
<< ND->getDeclName();
|
<< ND->getDeclName();
|
||||||
|
@ -2893,7 +2892,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
|
||||||
SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd());
|
SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd());
|
||||||
Diag(Loc, diag::err_member_reference_needs_call)
|
Diag(Loc, diag::err_member_reference_needs_call)
|
||||||
<< QualType(Fun, 0)
|
<< QualType(Fun, 0)
|
||||||
<< CodeModificationHint::CreateInsertion(Loc, "()");
|
<< FixItHint::CreateInsertion(Loc, "()");
|
||||||
|
|
||||||
OwningExprResult NewBase
|
OwningExprResult NewBase
|
||||||
= ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc,
|
= ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc,
|
||||||
|
@ -3012,7 +3011,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
|
||||||
// by now.
|
// by now.
|
||||||
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
||||||
<< BaseType << int(IsArrow) << BaseExpr->getSourceRange()
|
<< BaseType << int(IsArrow) << BaseExpr->getSourceRange()
|
||||||
<< CodeModificationHint::CreateReplacement(OpLoc, ".");
|
<< FixItHint::CreateReplacement(OpLoc, ".");
|
||||||
IsArrow = false;
|
IsArrow = false;
|
||||||
} else {
|
} else {
|
||||||
Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
|
Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
|
||||||
|
@ -3032,7 +3031,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
|
||||||
if (PT && PT->getPointeeType()->isRecordType()) {
|
if (PT && PT->getPointeeType()->isRecordType()) {
|
||||||
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
||||||
<< BaseType << int(IsArrow) << BaseExpr->getSourceRange()
|
<< BaseType << int(IsArrow) << BaseExpr->getSourceRange()
|
||||||
<< CodeModificationHint::CreateReplacement(OpLoc, "->");
|
<< FixItHint::CreateReplacement(OpLoc, "->");
|
||||||
BaseType = PT->getPointeeType();
|
BaseType = PT->getPointeeType();
|
||||||
IsArrow = true;
|
IsArrow = true;
|
||||||
}
|
}
|
||||||
|
@ -3071,8 +3070,8 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
|
||||||
Diag(R.getNameLoc(),
|
Diag(R.getNameLoc(),
|
||||||
diag::err_typecheck_member_reference_ivar_suggest)
|
diag::err_typecheck_member_reference_ivar_suggest)
|
||||||
<< IDecl->getDeclName() << MemberName << IV->getDeclName()
|
<< IDecl->getDeclName() << MemberName << IV->getDeclName()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
IV->getNameAsString());
|
IV->getNameAsString());
|
||||||
Diag(IV->getLocation(), diag::note_previous_decl)
|
Diag(IV->getLocation(), diag::note_previous_decl)
|
||||||
<< IV->getDeclName();
|
<< IV->getDeclName();
|
||||||
}
|
}
|
||||||
|
@ -3246,8 +3245,8 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
|
||||||
Res.getAsSingle<ObjCPropertyDecl>()) {
|
Res.getAsSingle<ObjCPropertyDecl>()) {
|
||||||
Diag(R.getNameLoc(), diag::err_property_not_found_suggest)
|
Diag(R.getNameLoc(), diag::err_property_not_found_suggest)
|
||||||
<< MemberName << BaseType << Res.getLookupName()
|
<< MemberName << BaseType << Res.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
|
<< FixItHint::CreateReplacement(R.getNameLoc(),
|
||||||
Res.getLookupName().getAsString());
|
Res.getLookupName().getAsString());
|
||||||
ObjCPropertyDecl *Property = Res.getAsSingle<ObjCPropertyDecl>();
|
ObjCPropertyDecl *Property = Res.getAsSingle<ObjCPropertyDecl>();
|
||||||
Diag(Property->getLocation(), diag::note_previous_decl)
|
Diag(Property->getLocation(), diag::note_previous_decl)
|
||||||
<< Property->getDeclName();
|
<< Property->getDeclName();
|
||||||
|
@ -3576,7 +3575,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
|
||||||
if (NumArgs > 0) {
|
if (NumArgs > 0) {
|
||||||
// Pseudo-destructor calls should not have any arguments.
|
// Pseudo-destructor calls should not have any arguments.
|
||||||
Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args)
|
Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(
|
||||||
SourceRange(Args[0]->getLocStart(),
|
SourceRange(Args[0]->getLocStart(),
|
||||||
Args[NumArgs-1]->getLocEnd()));
|
Args[NumArgs-1]->getLocEnd()));
|
||||||
|
|
||||||
|
@ -5426,12 +5425,10 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
|
||||||
PDiag(diag::warn_stringcompare)
|
PDiag(diag::warn_stringcompare)
|
||||||
<< isa<ObjCEncodeExpr>(literalStringStripped)
|
<< isa<ObjCEncodeExpr>(literalStringStripped)
|
||||||
<< literalString->getSourceRange()
|
<< literalString->getSourceRange()
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(Loc), ", ")
|
<< FixItHint::CreateReplacement(SourceRange(Loc), ", ")
|
||||||
<< CodeModificationHint::CreateInsertion(lex->getLocStart(),
|
<< FixItHint::CreateInsertion(lex->getLocStart(), "strcmp(")
|
||||||
"strcmp(")
|
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(rex->getLocEnd()),
|
||||||
<< CodeModificationHint::CreateInsertion(
|
resultComparison));
|
||||||
PP.getLocForEndOfToken(rex->getLocEnd()),
|
|
||||||
resultComparison));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6415,8 +6412,8 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc,
|
||||||
}
|
}
|
||||||
|
|
||||||
Self.Diag(Loc, PD)
|
Self.Diag(Loc, PD)
|
||||||
<< CodeModificationHint::CreateInsertion(ParenRange.getBegin(), "(")
|
<< FixItHint::CreateInsertion(ParenRange.getBegin(), "(")
|
||||||
<< CodeModificationHint::CreateInsertion(EndLoc, ")");
|
<< FixItHint::CreateInsertion(EndLoc, ")");
|
||||||
|
|
||||||
if (!SecondPD.getDiagID())
|
if (!SecondPD.getDiagID())
|
||||||
return;
|
return;
|
||||||
|
@ -6430,8 +6427,8 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc,
|
||||||
}
|
}
|
||||||
|
|
||||||
Self.Diag(Loc, SecondPD)
|
Self.Diag(Loc, SecondPD)
|
||||||
<< CodeModificationHint::CreateInsertion(SecondParenRange.getBegin(), "(")
|
<< FixItHint::CreateInsertion(SecondParenRange.getBegin(), "(")
|
||||||
<< CodeModificationHint::CreateInsertion(EndLoc, ")");
|
<< FixItHint::CreateInsertion(EndLoc, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison
|
/// DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison
|
||||||
|
@ -7135,11 +7132,8 @@ Sema::OwningExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
|
||||||
return Owned(new (Context) GNUNullExpr(Ty, TokenLoc));
|
return Owned(new (Context) GNUNullExpr(Ty, TokenLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void MakeObjCStringLiteralFixItHint(Sema& SemaRef, QualType DstType,
|
||||||
MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef,
|
Expr *SrcExpr, FixItHint &Hint) {
|
||||||
QualType DstType,
|
|
||||||
Expr *SrcExpr,
|
|
||||||
CodeModificationHint &Hint) {
|
|
||||||
if (!SemaRef.getLangOptions().ObjC1)
|
if (!SemaRef.getLangOptions().ObjC1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -7160,7 +7154,7 @@ MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef,
|
||||||
if (!SL || SL->isWide())
|
if (!SL || SL->isWide())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Hint = CodeModificationHint::CreateInsertion(SL->getLocStart(), "@");
|
Hint = FixItHint::CreateInsertion(SL->getLocStart(), "@");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
||||||
|
@ -7170,7 +7164,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
||||||
// Decode the result (notice that AST's are still created for extensions).
|
// Decode the result (notice that AST's are still created for extensions).
|
||||||
bool isInvalid = false;
|
bool isInvalid = false;
|
||||||
unsigned DiagKind;
|
unsigned DiagKind;
|
||||||
CodeModificationHint Hint;
|
FixItHint Hint;
|
||||||
|
|
||||||
switch (ConvTy) {
|
switch (ConvTy) {
|
||||||
default: assert(0 && "Unknown conversion type");
|
default: assert(0 && "Unknown conversion type");
|
||||||
|
@ -7182,7 +7176,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
||||||
DiagKind = diag::ext_typecheck_convert_int_pointer;
|
DiagKind = diag::ext_typecheck_convert_int_pointer;
|
||||||
break;
|
break;
|
||||||
case IncompatiblePointer:
|
case IncompatiblePointer:
|
||||||
MakeObjCStringLiteralCodeModificationHint(*this, DstType, SrcExpr, Hint);
|
MakeObjCStringLiteralFixItHint(*this, DstType, SrcExpr, Hint);
|
||||||
DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
|
DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
|
||||||
break;
|
break;
|
||||||
case IncompatiblePointerSign:
|
case IncompatiblePointerSign:
|
||||||
|
@ -7549,10 +7543,10 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
|
||||||
|
|
||||||
Diag(Loc, diagnostic)
|
Diag(Loc, diagnostic)
|
||||||
<< E->getSourceRange()
|
<< E->getSourceRange()
|
||||||
<< CodeModificationHint::CreateInsertion(Open, "(")
|
<< FixItHint::CreateInsertion(Open, "(")
|
||||||
<< CodeModificationHint::CreateInsertion(Close, ")");
|
<< FixItHint::CreateInsertion(Close, ")");
|
||||||
Diag(Loc, diag::note_condition_assign_to_comparison)
|
Diag(Loc, diag::note_condition_assign_to_comparison)
|
||||||
<< CodeModificationHint::CreateReplacement(Loc, "==");
|
<< FixItHint::CreateReplacement(Loc, "==");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sema::CheckBooleanCondition(Expr *&E, SourceLocation Loc) {
|
bool Sema::CheckBooleanCondition(Expr *&E, SourceLocation Loc) {
|
||||||
|
|
|
@ -1858,7 +1858,7 @@ QualType Sema::CheckPointerToMemberOperands(
|
||||||
else {
|
else {
|
||||||
Diag(Loc, diag::err_bad_memptr_lhs)
|
Diag(Loc, diag::err_bad_memptr_lhs)
|
||||||
<< OpSpelling << 1 << LType
|
<< OpSpelling << 1 << LType
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(Loc), ".*");
|
<< FixItHint::CreateReplacement(SourceRange(Loc), ".*");
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2589,7 +2589,7 @@ Sema::OwningExprResult Sema::DiagnoseDtorReference(SourceLocation NameLoc,
|
||||||
SourceLocation ExpectedLParenLoc = PP.getLocForEndOfToken(NameLoc);
|
SourceLocation ExpectedLParenLoc = PP.getLocForEndOfToken(NameLoc);
|
||||||
Diag(E->getLocStart(), diag::err_dtor_expr_without_call)
|
Diag(E->getLocStart(), diag::err_dtor_expr_without_call)
|
||||||
<< isa<CXXPseudoDestructorExpr>(E)
|
<< isa<CXXPseudoDestructorExpr>(E)
|
||||||
<< CodeModificationHint::CreateInsertion(ExpectedLParenLoc, "()");
|
<< FixItHint::CreateInsertion(ExpectedLParenLoc, "()");
|
||||||
|
|
||||||
return ActOnCallExpr(/*Scope*/ 0,
|
return ActOnCallExpr(/*Scope*/ 0,
|
||||||
move(MemExpr),
|
move(MemExpr),
|
||||||
|
@ -2623,7 +2623,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
|
||||||
// The user wrote "p->" when she probably meant "p."; fix it.
|
// The user wrote "p->" when she probably meant "p."; fix it.
|
||||||
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
||||||
<< ObjectType << true
|
<< ObjectType << true
|
||||||
<< CodeModificationHint::CreateReplacement(OpLoc, ".");
|
<< FixItHint::CreateReplacement(OpLoc, ".");
|
||||||
if (isSFINAEContext())
|
if (isSFINAEContext())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
|
||||||
|
@ -2728,7 +2728,7 @@ Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
|
||||||
// The user wrote "p->" when she probably meant "p."; fix it.
|
// The user wrote "p->" when she probably meant "p."; fix it.
|
||||||
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
|
||||||
<< ObjectType << true
|
<< ObjectType << true
|
||||||
<< CodeModificationHint::CreateReplacement(OpLoc, ".");
|
<< FixItHint::CreateReplacement(OpLoc, ".");
|
||||||
if (isSFINAEContext())
|
if (isSFINAEContext())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
|
||||||
|
|
|
@ -504,13 +504,11 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity,
|
||||||
SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
|
SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
|
||||||
diag::warn_missing_braces)
|
diag::warn_missing_braces)
|
||||||
<< StructuredSubobjectInitList->getSourceRange()
|
<< StructuredSubobjectInitList->getSourceRange()
|
||||||
<< CodeModificationHint::CreateInsertion(
|
<< FixItHint::CreateInsertion(StructuredSubobjectInitList->getLocStart(),
|
||||||
StructuredSubobjectInitList->getLocStart(),
|
"{")
|
||||||
"{")
|
<< FixItHint::CreateInsertion(SemaRef.PP.getLocForEndOfToken(
|
||||||
<< CodeModificationHint::CreateInsertion(
|
|
||||||
SemaRef.PP.getLocForEndOfToken(
|
|
||||||
StructuredSubobjectInitList->getLocEnd()),
|
StructuredSubobjectInitList->getLocEnd()),
|
||||||
"}");
|
"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,8 +569,8 @@ void InitListChecker::CheckExplicitInitList(const InitializedEntity &Entity,
|
||||||
if (T->isScalarType() && !TopLevelObject)
|
if (T->isScalarType() && !TopLevelObject)
|
||||||
SemaRef.Diag(IList->getLocStart(), diag::warn_braces_around_scalar_init)
|
SemaRef.Diag(IList->getLocStart(), diag::warn_braces_around_scalar_init)
|
||||||
<< IList->getSourceRange()
|
<< IList->getSourceRange()
|
||||||
<< CodeModificationHint::CreateRemoval(IList->getLocStart())
|
<< FixItHint::CreateRemoval(IList->getLocStart())
|
||||||
<< CodeModificationHint::CreateRemoval(IList->getLocEnd());
|
<< FixItHint::CreateRemoval(IList->getLocEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity,
|
void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity,
|
||||||
|
@ -1363,8 +1361,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
|
||||||
SemaRef.Diag(D->getFieldLoc(),
|
SemaRef.Diag(D->getFieldLoc(),
|
||||||
diag::err_field_designator_unknown_suggest)
|
diag::err_field_designator_unknown_suggest)
|
||||||
<< FieldName << CurrentObjectType << R.getLookupName()
|
<< FieldName << CurrentObjectType << R.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(D->getFieldLoc(),
|
<< FixItHint::CreateReplacement(D->getFieldLoc(),
|
||||||
R.getLookupName().getAsString());
|
R.getLookupName().getAsString());
|
||||||
SemaRef.Diag(ReplacementField->getLocation(),
|
SemaRef.Diag(ReplacementField->getLocation(),
|
||||||
diag::note_previous_decl)
|
diag::note_previous_decl)
|
||||||
<< ReplacementField->getDeclName();
|
<< ReplacementField->getDeclName();
|
||||||
|
|
|
@ -471,9 +471,9 @@ static bool CheckCXXSwitchCondition(Sema &S, SourceLocation SwitchLoc,
|
||||||
|
|
||||||
S.Diag(SwitchLoc, diag::err_switch_explicit_conversion)
|
S.Diag(SwitchLoc, diag::err_switch_explicit_conversion)
|
||||||
<< CondType << ConvTy << CondExpr->getSourceRange()
|
<< CondType << ConvTy << CondExpr->getSourceRange()
|
||||||
<< CodeModificationHint::CreateInsertion(CondExpr->getLocStart(),
|
<< FixItHint::CreateInsertion(CondExpr->getLocStart(),
|
||||||
"static_cast<" + TypeStr + ">(")
|
"static_cast<" + TypeStr + ">(")
|
||||||
<< CodeModificationHint::CreateInsertion(
|
<< FixItHint::CreateInsertion(
|
||||||
S.PP.getLocForEndOfToken(CondExpr->getLocEnd()),
|
S.PP.getLocForEndOfToken(CondExpr->getLocEnd()),
|
||||||
")");
|
")");
|
||||||
S.Diag(Conversion->getLocation(), diag::note_switch_conversion)
|
S.Diag(Conversion->getLocation(), diag::note_switch_conversion)
|
||||||
|
|
|
@ -161,7 +161,7 @@ bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II,
|
||||||
NestedNameSpecifier *Qualifier = (NestedNameSpecifier*)SS->getScopeRep();
|
NestedNameSpecifier *Qualifier = (NestedNameSpecifier*)SS->getScopeRep();
|
||||||
Diag(IILoc, diag::err_template_kw_missing)
|
Diag(IILoc, diag::err_template_kw_missing)
|
||||||
<< Qualifier << II.getName()
|
<< Qualifier << II.getName()
|
||||||
<< CodeModificationHint::CreateInsertion(IILoc, "template ");
|
<< FixItHint::CreateInsertion(IILoc, "template ");
|
||||||
SuggestedTemplate
|
SuggestedTemplate
|
||||||
= TemplateTy::make(Context.getDependentTemplateName(Qualifier, &II));
|
= TemplateTy::make(Context.getDependentTemplateName(Qualifier, &II));
|
||||||
SuggestedKind = TNK_Dependent_template_name;
|
SuggestedKind = TNK_Dependent_template_name;
|
||||||
|
@ -240,12 +240,12 @@ void Sema::LookupTemplateName(LookupResult &Found,
|
||||||
if (LookupCtx)
|
if (LookupCtx)
|
||||||
Diag(Found.getNameLoc(), diag::err_no_member_template_suggest)
|
Diag(Found.getNameLoc(), diag::err_no_member_template_suggest)
|
||||||
<< Name << LookupCtx << Found.getLookupName() << SS.getRange()
|
<< Name << LookupCtx << Found.getLookupName() << SS.getRange()
|
||||||
<< CodeModificationHint::CreateReplacement(Found.getNameLoc(),
|
<< FixItHint::CreateReplacement(Found.getNameLoc(),
|
||||||
Found.getLookupName().getAsString());
|
Found.getLookupName().getAsString());
|
||||||
else
|
else
|
||||||
Diag(Found.getNameLoc(), diag::err_no_template_suggest)
|
Diag(Found.getNameLoc(), diag::err_no_template_suggest)
|
||||||
<< Name << Found.getLookupName()
|
<< Name << Found.getLookupName()
|
||||||
<< CodeModificationHint::CreateReplacement(Found.getNameLoc(),
|
<< FixItHint::CreateReplacement(Found.getNameLoc(),
|
||||||
Found.getLookupName().getAsString());
|
Found.getLookupName().getAsString());
|
||||||
if (TemplateDecl *Template = Found.getAsSingle<TemplateDecl>())
|
if (TemplateDecl *Template = Found.getAsSingle<TemplateDecl>())
|
||||||
Diag(Template->getLocation(), diag::note_previous_decl)
|
Diag(Template->getLocation(), diag::note_previous_decl)
|
||||||
|
@ -822,8 +822,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
||||||
if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind, KWLoc, *Name)) {
|
if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind, KWLoc, *Name)) {
|
||||||
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
||||||
<< Name
|
<< Name
|
||||||
<< CodeModificationHint::CreateReplacement(KWLoc,
|
<< FixItHint::CreateReplacement(KWLoc, PrevRecordDecl->getKindName());
|
||||||
PrevRecordDecl->getKindName());
|
|
||||||
Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
|
Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
|
||||||
Kind = PrevRecordDecl->getTagKind();
|
Kind = PrevRecordDecl->getTagKind();
|
||||||
}
|
}
|
||||||
|
@ -1295,8 +1294,7 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
|
||||||
} else {
|
} else {
|
||||||
Diag(SS.getRange().getBegin(), diag::err_template_spec_needs_header)
|
Diag(SS.getRange().getBegin(), diag::err_template_spec_needs_header)
|
||||||
<< SS.getRange()
|
<< SS.getRange()
|
||||||
<< CodeModificationHint::CreateInsertion(FirstTemplateLoc,
|
<< FixItHint::CreateInsertion(FirstTemplateLoc, "template<> ");
|
||||||
"template<> ");
|
|
||||||
IsExplicitSpecialization = true;
|
IsExplicitSpecialization = true;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1499,8 +1497,7 @@ Sema::TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult,
|
||||||
if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) {
|
if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) {
|
||||||
Diag(TagLoc, diag::err_use_with_wrong_tag)
|
Diag(TagLoc, diag::err_use_with_wrong_tag)
|
||||||
<< Type
|
<< Type
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(TagLoc),
|
<< FixItHint::CreateReplacement(SourceRange(TagLoc), D->getKindName());
|
||||||
D->getKindName());
|
|
||||||
Diag(D->getLocation(), diag::note_previous_use);
|
Diag(D->getLocation(), diag::note_previous_use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3463,7 +3460,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
|
||||||
} else if (TemplateParams) {
|
} else if (TemplateParams) {
|
||||||
if (TUK == TUK_Friend)
|
if (TUK == TUK_Friend)
|
||||||
Diag(KWLoc, diag::err_template_spec_friend)
|
Diag(KWLoc, diag::err_template_spec_friend)
|
||||||
<< CodeModificationHint::CreateRemoval(
|
<< FixItHint::CreateRemoval(
|
||||||
SourceRange(TemplateParams->getTemplateLoc(),
|
SourceRange(TemplateParams->getTemplateLoc(),
|
||||||
TemplateParams->getRAngleLoc()))
|
TemplateParams->getRAngleLoc()))
|
||||||
<< SourceRange(LAngleLoc, RAngleLoc);
|
<< SourceRange(LAngleLoc, RAngleLoc);
|
||||||
|
@ -3471,7 +3468,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
|
||||||
isExplicitSpecialization = true;
|
isExplicitSpecialization = true;
|
||||||
} else if (TUK != TUK_Friend) {
|
} else if (TUK != TUK_Friend) {
|
||||||
Diag(KWLoc, diag::err_template_spec_needs_header)
|
Diag(KWLoc, diag::err_template_spec_needs_header)
|
||||||
<< CodeModificationHint::CreateInsertion(KWLoc, "template<> ");
|
<< FixItHint::CreateInsertion(KWLoc, "template<> ");
|
||||||
isExplicitSpecialization = true;
|
isExplicitSpecialization = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3489,7 +3486,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
|
||||||
*ClassTemplate->getIdentifier())) {
|
*ClassTemplate->getIdentifier())) {
|
||||||
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
||||||
<< ClassTemplate
|
<< ClassTemplate
|
||||||
<< CodeModificationHint::CreateReplacement(KWLoc,
|
<< FixItHint::CreateReplacement(KWLoc,
|
||||||
ClassTemplate->getTemplatedDecl()->getKindName());
|
ClassTemplate->getTemplatedDecl()->getKindName());
|
||||||
Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
|
Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
|
||||||
diag::note_previous_use);
|
diag::note_previous_use);
|
||||||
|
@ -3531,8 +3528,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
|
||||||
// to the implicit argument list of the primary template.
|
// to the implicit argument list of the primary template.
|
||||||
Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
|
Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
|
||||||
<< (TUK == TUK_Definition)
|
<< (TUK == TUK_Definition)
|
||||||
<< CodeModificationHint::CreateRemoval(SourceRange(LAngleLoc,
|
<< FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc));
|
||||||
RAngleLoc));
|
|
||||||
return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
|
return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
|
||||||
ClassTemplate->getIdentifier(),
|
ClassTemplate->getIdentifier(),
|
||||||
TemplateNameLoc,
|
TemplateNameLoc,
|
||||||
|
@ -4379,7 +4375,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
|
||||||
*ClassTemplate->getIdentifier())) {
|
*ClassTemplate->getIdentifier())) {
|
||||||
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
Diag(KWLoc, diag::err_use_with_wrong_tag)
|
||||||
<< ClassTemplate
|
<< ClassTemplate
|
||||||
<< CodeModificationHint::CreateReplacement(KWLoc,
|
<< FixItHint::CreateReplacement(KWLoc,
|
||||||
ClassTemplate->getTemplatedDecl()->getKindName());
|
ClassTemplate->getTemplatedDecl()->getKindName());
|
||||||
Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
|
Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
|
||||||
diag::note_previous_use);
|
diag::note_previous_use);
|
||||||
|
@ -4697,7 +4693,7 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
|
||||||
if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x)
|
if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x)
|
||||||
Diag(D.getDeclSpec().getInlineSpecLoc(),
|
Diag(D.getDeclSpec().getInlineSpecLoc(),
|
||||||
diag::err_explicit_instantiation_inline)
|
diag::err_explicit_instantiation_inline)
|
||||||
<<CodeModificationHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
|
<<FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
|
||||||
|
|
||||||
// FIXME: check for constexpr specifier.
|
// FIXME: check for constexpr specifier.
|
||||||
|
|
||||||
|
|
|
@ -689,8 +689,8 @@ TemplateInstantiator::RebuildElaboratedType(QualType T,
|
||||||
if (!SemaRef.isAcceptableTagRedeclaration(TD, Tag, TagLocation, *Id)) {
|
if (!SemaRef.isAcceptableTagRedeclaration(TD, Tag, TagLocation, *Id)) {
|
||||||
SemaRef.Diag(TagLocation, diag::err_use_with_wrong_tag)
|
SemaRef.Diag(TagLocation, diag::err_use_with_wrong_tag)
|
||||||
<< Id
|
<< Id
|
||||||
<< CodeModificationHint::CreateReplacement(SourceRange(TagLocation),
|
<< FixItHint::CreateReplacement(SourceRange(TagLocation),
|
||||||
TD->getKindName());
|
TD->getKindName());
|
||||||
SemaRef.Diag(TD->getLocation(), diag::note_previous_use);
|
SemaRef.Diag(TD->getLocation(), diag::note_previous_use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,8 +183,7 @@ static QualType ConvertDeclSpecToType(Sema &TheSema,
|
||||||
if (DS.isEmpty()) {
|
if (DS.isEmpty()) {
|
||||||
TheSema.Diag(DeclLoc, diag::ext_missing_declspec)
|
TheSema.Diag(DeclLoc, diag::ext_missing_declspec)
|
||||||
<< DS.getSourceRange()
|
<< DS.getSourceRange()
|
||||||
<< CodeModificationHint::CreateInsertion(DS.getSourceRange().getBegin(),
|
<< FixItHint::CreateInsertion(DS.getSourceRange().getBegin(), "int");
|
||||||
"int");
|
|
||||||
}
|
}
|
||||||
} else if (!DS.hasTypeSpecifier()) {
|
} else if (!DS.hasTypeSpecifier()) {
|
||||||
// C99 and C++ require a type specifier. For example, C99 6.7.2p2 says:
|
// C99 and C++ require a type specifier. For example, C99 6.7.2p2 says:
|
||||||
|
|
|
@ -201,7 +201,7 @@ CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, unsigned FixIt,
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeModificationHint &Hint = StoredDiag->Diag.fixit_begin()[FixIt];
|
const FixItHint &Hint = StoredDiag->Diag.fixit_begin()[FixIt];
|
||||||
if (ReplacementRange) {
|
if (ReplacementRange) {
|
||||||
if (Hint.RemoveRange.isInvalid()) {
|
if (Hint.RemoveRange.isInvalid()) {
|
||||||
// Create an empty range that refers to a single source
|
// Create an empty range that refers to a single source
|
||||||
|
|
Loading…
Reference in New Issue