summaryrefslogtreecommitdiffstats
path: root/clang/include/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include/clang')
-rw-r--r--clang/include/clang/AST/Statistics.h13
-rw-r--r--clang/include/clang/Basic/Diagnostic.h69
-rw-r--r--clang/include/clang/Basic/PartialDiagnostic.h30
-rw-r--r--clang/include/clang/Checker/BugReporter/PathDiagnostic.h18
-rw-r--r--clang/include/clang/Frontend/TextDiagnosticPrinter.h2
5 files changed, 70 insertions, 62 deletions
diff --git a/clang/include/clang/AST/Statistics.h b/clang/include/clang/AST/Statistics.h
index 052135b8f60..fc1abae302c 100644
--- a/clang/include/clang/AST/Statistics.h
+++ b/clang/include/clang/AST/Statistics.h
@@ -14,6 +14,8 @@
#ifndef LLVM_CLANG_AST_STATISTICS_H
#define LLVM_CLANG_AST_STATISTICS_H
+#define CLANG_C_ONLY 1
+
#ifndef NDEBUG
#include "llvm/ADT/Statistic.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
#define CLANG_ISA_STATISTIC(Type,Counter)
#endif
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 3b8c3c30266..643868506d8 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -95,7 +95,7 @@ namespace clang {
/// should also provide full recovery from such errors, such that
/// suppressing the diagnostic output can still result in successful
/// compilation.
-class CodeModificationHint {
+class FixItHint {
public:
/// \brief Tokens that should be removed to correct the error.
SourceRange RemoveRange;
@@ -110,7 +110,7 @@ public:
/// \brief Empty code modification hint, indicating that no code
/// modification is known.
- CodeModificationHint() : RemoveRange(), InsertionLoc() { }
+ FixItHint() : RemoveRange(), InsertionLoc() { }
bool isNull() const {
return !RemoveRange.isValid() && !InsertionLoc.isValid();
@@ -118,9 +118,9 @@ public:
/// \brief Create a code modification hint that inserts the given
/// code string at a specific location.
- static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc,
- llvm::StringRef Code) {
- CodeModificationHint Hint;
+ static FixItHint CreateInsertion(SourceLocation InsertionLoc,
+ llvm::StringRef Code) {
+ FixItHint Hint;
Hint.InsertionLoc = InsertionLoc;
Hint.CodeToInsert = Code;
return Hint;
@@ -128,17 +128,17 @@ public:
/// \brief Create a code modification hint that removes the given
/// source range.
- static CodeModificationHint CreateRemoval(SourceRange RemoveRange) {
- CodeModificationHint Hint;
+ static FixItHint CreateRemoval(SourceRange RemoveRange) {
+ FixItHint Hint;
Hint.RemoveRange = RemoveRange;
return Hint;
}
/// \brief Create a code modification hint that replaces the given
/// source range with the given code string.
- static CodeModificationHint CreateReplacement(SourceRange RemoveRange,
- llvm::StringRef Code) {
- CodeModificationHint Hint;
+ static FixItHint CreateReplacement(SourceRange RemoveRange,
+ llvm::StringRef Code) {
+ FixItHint Hint;
Hint.RemoveRange = RemoveRange;
Hint.InsertionLoc = RemoveRange.getBegin();
Hint.CodeToInsert = Code;
@@ -519,8 +519,8 @@ private:
/// NumRanges - This is the number of ranges in the DiagRanges array.
unsigned char NumDiagRanges;
/// \brief The number of code modifications hints in the
- /// CodeModificationHints array.
- unsigned char NumCodeModificationHints;
+ /// FixItHints array.
+ unsigned char NumFixItHints;
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
/// 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.
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.
- CodeModificationHint CodeModificationHints[MaxCodeModificationHints];
+ FixItHint FixItHints[MaxFixItHints];
/// ProcessDiag - This is the method used to report a diagnostic that is
/// finally fully formed.
@@ -573,13 +573,12 @@ private:
/// for example.
class DiagnosticBuilder {
mutable Diagnostic *DiagObj;
- mutable unsigned NumArgs, NumRanges, NumCodeModificationHints;
+ mutable unsigned NumArgs, NumRanges, NumFixItHints;
void operator=(const DiagnosticBuilder&); // DO NOT IMPLEMENT
friend class Diagnostic;
explicit DiagnosticBuilder(Diagnostic *diagObj)
- : DiagObj(diagObj), NumArgs(0), NumRanges(0),
- NumCodeModificationHints(0) {}
+ : DiagObj(diagObj), NumArgs(0), NumRanges(0), NumFixItHints(0) {}
public:
/// Copy constructor. When copied, this "takes" the diagnostic info from the
@@ -589,7 +588,7 @@ public:
D.DiagObj = 0;
NumArgs = D.NumArgs;
NumRanges = D.NumRanges;
- NumCodeModificationHints = D.NumCodeModificationHints;
+ NumFixItHints = D.NumFixItHints;
}
/// \brief Simple enumeration value used to give a name to the
@@ -599,7 +598,7 @@ public:
/// \brief Create an empty DiagnosticBuilder object that represents
/// no actual diagnostic.
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.
///
@@ -648,14 +647,14 @@ public:
DiagObj->DiagRanges[NumRanges++] = R;
}
- void AddCodeModificationHint(const CodeModificationHint &Hint) const {
+ void AddFixItHint(const FixItHint &Hint) const {
if (Hint.isNull())
return;
- assert(NumCodeModificationHints < Diagnostic::MaxCodeModificationHints &&
- "Too many code modification hints!");
+ assert(NumFixItHints < Diagnostic::MaxFixItHints &&
+ "Too many fix-it hints!");
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,
- const CodeModificationHint &Hint) {
- DB.AddCodeModificationHint(Hint);
+ const FixItHint &Hint) {
+ DB.AddFixItHint(Hint);
return DB;
}
@@ -813,17 +812,17 @@ public:
return DiagObj->DiagRanges[Idx];
}
- unsigned getNumCodeModificationHints() const {
- return DiagObj->NumCodeModificationHints;
+ unsigned getNumFixItHints() const {
+ return DiagObj->NumFixItHints;
}
- const CodeModificationHint &getCodeModificationHint(unsigned Idx) const {
- return DiagObj->CodeModificationHints[Idx];
+ const FixItHint &getFixItHint(unsigned Idx) const {
+ return DiagObj->FixItHints[Idx];
}
- const CodeModificationHint *getCodeModificationHints() const {
- return DiagObj->NumCodeModificationHints?
- &DiagObj->CodeModificationHints[0] : 0;
+ const FixItHint *getFixItHints() const {
+ return DiagObj->NumFixItHints?
+ &DiagObj->FixItHints[0] : 0;
}
/// FormatDiagnostic - Format this diagnostic into a string, substituting the
@@ -846,7 +845,7 @@ class StoredDiagnostic {
FullSourceLoc Loc;
std::string Message;
std::vector<SourceRange> Ranges;
- std::vector<CodeModificationHint> FixIts;
+ std::vector<FixItHint> FixIts;
public:
StoredDiagnostic();
@@ -866,7 +865,7 @@ public:
range_iterator range_end() const { return Ranges.end(); }
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_end() const { return FixIts.end(); }
unsigned fixit_size() const { return FixIts.size(); }
diff --git a/clang/include/clang/Basic/PartialDiagnostic.h b/clang/include/clang/Basic/PartialDiagnostic.h
index d49e621d2f1..de858eadb68 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -29,8 +29,7 @@ class DeclarationName;
class PartialDiagnostic {
public:
struct Storage {
- Storage() : NumDiagArgs(0), NumDiagRanges(0), NumCodeModificationHints(0) {
- }
+ Storage() : NumDiagArgs(0), NumDiagRanges(0), NumFixItHints(0) { }
enum {
/// MaxArguments - The maximum number of arguments we can hold. We
@@ -47,8 +46,8 @@ public:
unsigned char NumDiagRanges;
/// \brief The number of code modifications hints in the
- /// CodeModificationHints array.
- unsigned char NumCodeModificationHints;
+ /// FixItHints array.
+ unsigned char NumFixItHints;
/// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum
/// 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.
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.
- CodeModificationHint CodeModificationHints[MaxCodeModificationHints];
+ FixItHint FixItHints[MaxFixItHints];
};
/// \brief An allocator for Storage objects, which uses a small cache to
@@ -92,7 +91,7 @@ public:
Storage *Result = FreeList[--NumFreeListEntries];
Result->NumDiagArgs = 0;
Result->NumDiagRanges = 0;
- Result->NumCodeModificationHints = 0;
+ Result->NumFixItHints = 0;
return Result;
}
@@ -166,17 +165,16 @@ private:
DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R;
}
- void AddCodeModificationHint(const CodeModificationHint &Hint) const {
+ void AddFixItHint(const FixItHint &Hint) const {
if (Hint.isNull())
return;
if (!DiagStorage)
DiagStorage = getStorage();
- assert(DiagStorage->NumCodeModificationHints <
- Storage::MaxCodeModificationHints &&
+ assert(DiagStorage->NumFixItHints < Storage::MaxFixItHints &&
"Too many code modification hints!");
- DiagStorage->CodeModificationHints[DiagStorage->NumCodeModificationHints++]
+ DiagStorage->FixItHints[DiagStorage->NumFixItHints++]
= Hint;
}
@@ -236,8 +234,8 @@ public:
DB.AddSourceRange(DiagStorage->DiagRanges[i]);
// Add all code modification hints
- for (unsigned i = 0, e = DiagStorage->NumCodeModificationHints; i != e; ++i)
- DB.AddCodeModificationHint(DiagStorage->CodeModificationHints[i]);
+ for (unsigned i = 0, e = DiagStorage->NumFixItHints; i != e; ++i)
+ DB.AddFixItHint(DiagStorage->FixItHints[i]);
}
/// \brief Clear out this partial diagnostic, giving it a new diagnostic ID
@@ -284,8 +282,8 @@ public:
DeclarationName N);
friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
- const CodeModificationHint &Hint) {
- PD.AddCodeModificationHint(Hint);
+ const FixItHint &Hint) {
+ PD.AddFixItHint(Hint);
return PD;
}
diff --git a/clang/include/clang/Checker/BugReporter/PathDiagnostic.h b/clang/include/clang/Checker/BugReporter/PathDiagnostic.h
index d380c45480c..24c75ce7b22 100644
--- a/clang/include/clang/Checker/BugReporter/PathDiagnostic.h
+++ b/clang/include/clang/Checker/BugReporter/PathDiagnostic.h
@@ -168,7 +168,7 @@ public:
private:
const std::string str;
- std::vector<CodeModificationHint> CodeModificationHints;
+ std::vector<FixItHint> FixItHints;
const Kind kind;
const DisplayHint Hint;
std::vector<SourceRange> ranges;
@@ -203,8 +203,8 @@ public:
ranges.push_back(SourceRange(B,E));
}
- void addCodeModificationHint(const CodeModificationHint& Hint) {
- CodeModificationHints.push_back(Hint);
+ void addFixItHint(const FixItHint& Hint) {
+ FixItHints.push_back(Hint);
}
typedef const SourceRange* range_iterator;
@@ -217,15 +217,15 @@ public:
return ranges_begin() + ranges.size();
}
- typedef const CodeModificationHint *code_modifications_iterator;
+ typedef const FixItHint *fixit_iterator;
- code_modifications_iterator code_modifications_begin() const {
- return CodeModificationHints.empty()? 0 : &CodeModificationHints[0];
+ fixit_iterator fixit_begin() const {
+ return FixItHints.empty()? 0 : &FixItHints[0];
}
- code_modifications_iterator code_modifications_end() const {
- return CodeModificationHints.empty()? 0
- : &CodeModificationHints[0] + CodeModificationHints.size();
+ fixit_iterator fixit_end() const {
+ return FixItHints.empty()? 0
+ : &FixItHints[0] + FixItHints.size();
}
static inline bool classof(const PathDiagnosticPiece* P) {
diff --git a/clang/include/clang/Frontend/TextDiagnosticPrinter.h b/clang/include/clang/Frontend/TextDiagnosticPrinter.h
index d09e51fd018..157876b59d3 100644
--- a/clang/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/clang/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -69,7 +69,7 @@ public:
void EmitCaretDiagnostic(SourceLocation Loc,
SourceRange *Ranges, unsigned NumRanges,
SourceManager &SM,
- const CodeModificationHint *Hints,
+ const FixItHint *Hints,
unsigned NumHints,
unsigned Columns);
OpenPOWER on IntegriCloud