return Filename.equals("<command line>");
}
+ /// Returns whether \p Loc is located in a <scratch space> file.
+ bool isWrittenInScratchSpace(SourceLocation Loc) const {
+ StringRef Filename(getPresumedLoc(Loc).getFilename());
+ return Filename.equals("<scratch space>");
+ }
+
/// Returns if a SourceLocation is in a system header.
bool isInSystemHeader(SourceLocation Loc) const {
return isSystem(getFileCharacteristic(Loc));
/// Returns whether \p Loc is expanded from a macro in a system header.
bool isInSystemMacro(SourceLocation loc) const {
- return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc));
+ if(!loc.isMacroID())
+ return false;
+
+ // This happens when the macro is the result of a paste, in that case
+ // its spelling is the scratch memory, so we take the parent context.
+ if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+ return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+ }
+ else {
+ return isInSystemHeader(getSpellingLoc(loc));
+ }
}
/// The size of the SLocEntry that \p FID represents.
--- /dev/null
+extern int __isnanf(float f);
+extern int __isnan(double f);
+extern int __isnanl(long double f);
+#define isnan(x) \
+ (sizeof (x) == sizeof (float) \
+ ? __isnanf (x) \
+ : sizeof (x) == sizeof (double) \
+ ? __isnan (x) : __isnanl (x))
+
--- /dev/null
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s
+// CHECK: warning:
+// CHECK: expanded from macro 'ISNAN'
+// CHECK: expanded from macro 'isnan'
+
+#include <warn-in-system-macro-def.c.inc>
+
+#define isnan(x) \
+ (sizeof (x) == sizeof (float) \
+ ? __isnanf (x) \
+ : sizeof (x) == sizeof (double) \
+ ? __isnan (x) : __isnanl (x))
+
+int main(void)
+{
+ double foo = 1.0;
+
+ if (ISNAN(foo))
+ return 1;
+ return 0;
+}