forked from OSchip/llvm-project
Fix false error message for function-style macro instance used as arguments in other function-style macros instances, and add test for it.
llvm-svn: 188036
This commit is contained in:
parent
4fa9c2cbc6
commit
91555bde88
|
@ -334,6 +334,12 @@ std::string getMacroUnexpandedString(clang::SourceRange Range,
|
|||
|
||||
// Get the expansion for a macro instance, given the information
|
||||
// provided by PPCallbacks.
|
||||
// FIXME: This doesn't support function-style macro instances
|
||||
// passed as arguments to another function-style macro. However,
|
||||
// since it still expands the inner arguments, it still
|
||||
// allows modularize to effectively work with respect to macro
|
||||
// consistency checking, although it displays the incorrect
|
||||
// expansion in error messages.
|
||||
std::string getMacroExpandedString(clang::Preprocessor &PP,
|
||||
llvm::StringRef MacroName,
|
||||
const clang::MacroInfo *MI,
|
||||
|
@ -1214,6 +1220,9 @@ void PreprocessorCallbacks::MacroExpands(const clang::Token &MacroNameTok,
|
|||
clang::SourceRange Range,
|
||||
const clang::MacroArgs *Args) {
|
||||
clang::SourceLocation Loc = Range.getBegin();
|
||||
// Ignore macro argument expansions.
|
||||
if (!Loc.isFileID())
|
||||
return;
|
||||
clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
|
||||
const clang::MacroInfo *MI = PP.getMacroInfo(II);
|
||||
std::string MacroName = II->getName().str();
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// Verification of fix for nested macro.
|
||||
|
||||
#define FUNCMACROINNER(a) a
|
||||
#define FUNCMACROOUTER(b, c) FUNCMACROINNER(b) + FUNCMACROINNER(c)
|
||||
int FuncMacroValue = FUNCMACROOUTER(1, 2);
|
|
@ -0,0 +1,3 @@
|
|||
# RUN: modularize %s -x c++
|
||||
|
||||
Inputs/NestedMacro.h
|
Loading…
Reference in New Issue