clang API Documentation
#include "clang/Frontend/DiagnosticRenderer.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditedSource.h"
#include "clang/Edit/EditsReceiver.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
Go to the source code of this file.
Functions | |
static StringRef | getImmediateMacroName (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
Retrieve the name of the immediate macro expansion. | |
static void | mergeFixits (ArrayRef< FixItHint > FixItHints, const SourceManager &SM, const LangOptions &LangOpts, SmallVectorImpl< FixItHint > &MergedFixits) |
static void | mapDiagnosticRanges (SourceLocation CaretLoc, ArrayRef< CharSourceRange > Ranges, SmallVectorImpl< CharSourceRange > &SpellingRanges, const SourceManager *SM) |
static StringRef getImmediateMacroName | ( | SourceLocation | Loc, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts | ||
) | [static] |
Retrieve the name of the immediate macro expansion.
This routine starts from a source location, and finds the name of the macro responsible for its immediate expansion. It looks through any intervening macro argument expansions to compute this. It returns a StringRef which refers to the SourceManager-owned buffer of the source where that macro name is spelled. Thus, the result shouldn't out-live that SourceManager.
This differs from Lexer::getImmediateMacroName in that any macro argument location will result in the topmost function macro that accepted it. e.g.
MAC1( MAC2(foo) )
for location of 'foo' token, this function will return "MAC1" while Lexer::getImmediateMacroName will return "MAC2".
Definition at line 42 of file DiagnosticRenderer.cpp.
References clang::SourceManager::getBufferData(), clang::SourceManager::getDecomposedLoc(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileID(), clang::SourceManager::getImmediateExpansionRange(), clang::SourceManager::getSpellingLoc(), clang::SourceManager::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and clang::Lexer::MeasureTokenLength().
static void mapDiagnosticRanges | ( | SourceLocation | CaretLoc, |
ArrayRef< CharSourceRange > | Ranges, | ||
SmallVectorImpl< CharSourceRange > & | SpellingRanges, | ||
const SourceManager * | SM | ||
) | [static] |
Definition at line 323 of file DiagnosticRenderer.cpp.
References clang::SourceManager::getFileID(), clang::SourceManager::getImmediateExpansionRange(), clang::SourceManager::getImmediateSpellingLoc(), clang::SourceManager::getSpellingLoc(), clang::SourceManager::isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
static void mergeFixits | ( | ArrayRef< FixItHint > | FixItHints, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts, | ||
SmallVectorImpl< FixItHint > & | MergedFixits | ||
) | [static] |
Definition at line 92 of file DiagnosticRenderer.cpp.
References clang::edit::EditedSource::applyRewrites(), clang::FixItHint::BeforePreviousInsertions, clang::FixItHint::CodeToInsert, clang::edit::EditedSource::commit(), clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), clang::edit::Commit::insert(), clang::FixItHint::InsertFromRange, clang::edit::Commit::insertFromRange(), clang::CharSourceRange::isTokenRange(), clang::CharSourceRange::isValid(), clang::edit::Commit::remove(), clang::FixItHint::RemoveRange, and clang::edit::Commit::replace().
Referenced by clang::DiagnosticRenderer::emitDiagnostic().