Don't special-case source locations for calls in macros
The source location for a call that's inside a macro body will,
by default, point into the macro definition itself. The original
logic was causing macro invocations to be overwritten, as I
explain here:
https://github.com/ROCm-Developer-Tools/HIP/issues/207#issuecomment-337521851
The existing PPCallbacks code is correctly rewriting macro
definitions, so the practical effect of this change is that AST
rewrites on code that's expanded from macros are no-ops.
It might be a performance optimisation to put a short-circiut at
the top of the AST callbacks to abort when faced with code that
was expanded from macros.
It might yet prove wise to do absolutely everything at lex-time...
[ROCm/hip commit: 4a794ed8c0]
Цей коміт міститься в:
@@ -531,28 +531,10 @@ private:
|
||||
}
|
||||
|
||||
size_t length = name.size();
|
||||
bool bReplace = true;
|
||||
if (SM->isMacroArgExpansion(sl)) {
|
||||
sl = SM->getImmediateSpellingLoc(sl);
|
||||
} else if (SM->isMacroBodyExpansion(sl)) {
|
||||
LangOptions DefaultLangOptions;
|
||||
SourceLocation sl_macro = SM->getExpansionLoc(sl);
|
||||
SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *SM, DefaultLangOptions);
|
||||
length = SM->getCharacterData(sl_end) - SM->getCharacterData(sl_macro);
|
||||
StringRef macroName = StringRef(SM->getCharacterData(sl_macro), length);
|
||||
if (CUDA_EXCLUDES.end() != CUDA_EXCLUDES.find(macroName)) {
|
||||
bReplace = false;
|
||||
} else {
|
||||
sl = sl_macro;
|
||||
}
|
||||
}
|
||||
|
||||
if (bReplace) {
|
||||
updateCounters(found->second, name);
|
||||
Replacement Rep(*SM, sl, length, hipCtr.hipName);
|
||||
FullSourceLoc fullSL(sl, *SM);
|
||||
insertReplacement(Rep, fullSL);
|
||||
}
|
||||
updateCounters(found->second, name);
|
||||
Replacement Rep(*SM, sl, length, hipCtr.hipName);
|
||||
FullSourceLoc fullSL(sl, *SM);
|
||||
insertReplacement(Rep, fullSL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача