summaryrefslogtreecommitdiff
path: root/devel/llvm-devel/files
diff options
context:
space:
mode:
Diffstat (limited to 'devel/llvm-devel/files')
-rw-r--r--devel/llvm-devel/files/patch-tools_clang_include_clang_Analysis_Analyses_PrintfFormatString.h21
-rw-r--r--devel/llvm-devel/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp25
-rw-r--r--devel/llvm-devel/files/patch-tools_clang_lib_Sema_SemaChecking.cpp45
3 files changed, 91 insertions, 0 deletions
diff --git a/devel/llvm-devel/files/patch-tools_clang_include_clang_Analysis_Analyses_PrintfFormatString.h b/devel/llvm-devel/files/patch-tools_clang_include_clang_Analysis_Analyses_PrintfFormatString.h
new file mode 100644
index 000000000000..65f72ac71095
--- /dev/null
+++ b/devel/llvm-devel/files/patch-tools_clang_include_clang_Analysis_Analyses_PrintfFormatString.h
@@ -0,0 +1,21 @@
+
+$FreeBSD$
+
+--- tools/clang/include/clang/Analysis/Analyses/PrintfFormatString.h.orig
++++ tools/clang/include/clang/Analysis/Analyses/PrintfFormatString.h
+@@ -57,6 +57,7 @@
+ InvalidSpecifier = 0,
+ // C99 conversion specifiers.
+ dArg, // 'd'
++ DArg, // 'D' FreeBSD specific specifiers
+ iArg, // 'i',
+ oArg, // 'o',
+ uArg, // 'u',
+@@ -82,6 +83,7 @@
+ ObjCObjArg, // '@'
+ // GlibC specific specifiers.
+ PrintErrno, // 'm'
++ bArg, // FreeBSD specific specifiers
+ // Specifier ranges.
+ IntArgBeg = dArg,
+ IntArgEnd = iArg,
diff --git a/devel/llvm-devel/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp b/devel/llvm-devel/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp
new file mode 100644
index 000000000000..50e951381e7d
--- /dev/null
+++ b/devel/llvm-devel/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp
@@ -0,0 +1,25 @@
+
+$FreeBSD$
+
+--- tools/clang/lib/Analysis/PrintfFormatString.cpp.orig
++++ tools/clang/lib/Analysis/PrintfFormatString.cpp
+@@ -369,11 +369,19 @@
+ case '@': k = ConversionSpecifier::ObjCObjArg; break;
+ // Glibc specific.
+ case 'm': k = ConversionSpecifier::PrintErrno; break;
++ // FreeBSD format extensions
++ case 'b': k = ConversionSpecifier::bArg; break; /* check for int and then char * */
++ case 'r': k = ConversionSpecifier::xArg; break;
++ case 'y': k = ConversionSpecifier::iArg; break;
++ case 'D': k = ConversionSpecifier::DArg; break; /* check for u_char * pointer and a char * string */
+ }
+ ConversionSpecifier CS(conversionPosition, k);
+ FS.setConversionSpecifier(CS);
+ if (CS.consumesDataArgument() && !FS.usesPositionalArg())
+ FS.setArgIndex(argIndex++);
++ // FreeBSD extension
++ if (k == ConversionSpecifier::bArg || k == ConversionSpecifier::DArg)
++ argIndex++;
+
+ if (k == ConversionSpecifier::InvalidSpecifier) {
+ // Assume the conversion takes one argument.
diff --git a/devel/llvm-devel/files/patch-tools_clang_lib_Sema_SemaChecking.cpp b/devel/llvm-devel/files/patch-tools_clang_lib_Sema_SemaChecking.cpp
new file mode 100644
index 000000000000..32917b92b8d0
--- /dev/null
+++ b/devel/llvm-devel/files/patch-tools_clang_lib_Sema_SemaChecking.cpp
@@ -0,0 +1,45 @@
+
+$FreeBSD$
+
+--- tools/clang/lib/Sema/SemaChecking.cpp.orig
++++ tools/clang/lib/Sema/SemaChecking.cpp
+@@ -1275,6 +1275,39 @@
+ CoveredArgs.set(argIndex);
+ }
+
++ // FreeBSD extensions
++ if (CS.getKind() == ConversionSpecifier::bArg || CS.getKind() == ConversionSpecifier::DArg) {
++ // claim the second argument
++ CoveredArgs.set(argIndex + 1);
++
++ // Now type check the data expression that matches the
++ // format specifier.
++ const Expr *Ex = getDataArg(argIndex);
++ QualType type = (CS.getKind() == ConversionSpecifier::bArg) ? S.Context.IntTy : S.Context.getPointerType(S.Context.UnsignedCharTy);
++ //const analyze_printf::ArgTypeResult &ATR = S.Context.IntTy;
++ const analyze_printf::ArgTypeResult &ATR = type;
++ if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType()))
++ S.Diag(getLocationOfByte(CS.getStart()),
++ diag::warn_printf_conversion_argument_type_mismatch)
++ << ATR.getRepresentativeType(S.Context) << Ex->getType()
++ << getFormatSpecifierRange(startSpecifier, specifierLen)
++ << Ex->getSourceRange();
++
++ // Now type check the data expression that matches the
++ // format specifier.
++ Ex = getDataArg(argIndex + 1);
++ const analyze_printf::ArgTypeResult &ATR2 = ArgTypeResult::CStrTy;
++ if (ATR2.isValid() && !ATR2.matchesType(S.Context, Ex->getType()))
++ S.Diag(getLocationOfByte(CS.getStart()),
++ diag::warn_printf_conversion_argument_type_mismatch)
++ << ATR2.getRepresentativeType(S.Context) << Ex->getType()
++ << getFormatSpecifierRange(startSpecifier, specifierLen)
++ << Ex->getSourceRange();
++
++ return true;
++ }
++ // END OF FREEBSD EXTENSIONS
++
+ // Check for using an Objective-C specific conversion specifier
+ // in a non-ObjC literal.
+ if (!IsObjCLiteral && CS.isObjCArg()) {