[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output
Zbigniew Sarbinowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 07:28:37 PDT 2017
zibi updated this revision to Diff 115643.
zibi added a comment.
Addressing the review.
https://reviews.llvm.org/D37861
Files:
lib/Frontend/PrintPreprocessedOutput.cpp
test/Preprocessor/pragma_assume_nonnull.c
Index: test/Preprocessor/pragma_assume_nonnull.c
===================================================================
--- test/Preprocessor/pragma_assume_nonnull.c
+++ test/Preprocessor/pragma_assume_nonnull.c
@@ -1,23 +1,13 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -E %s | FileCheck %s
-#ifndef NS_ASSUME_NONNULL_BEGIN
-#if __has_feature(assume_nonnull)
-#define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
-#define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
-#else
-#define NS_ASSUME_NONNULL_BEGIN
-#define NS_ASSUME_NONNULL_END
-#endif
-#endif
-
// CHECK: #pragma clang assume_nonnull begin
-NS_ASSUME_NONNULL_BEGIN
+#pragma clang assume_nonnull begin
int bar(int * ip) { return *ip; }
// CHECK: #pragma clang assume_nonnull end
-NS_ASSUME_NONNULL_END
+#pragma clang assume_nonnull end
int foo(int * _Nonnull ip) { return *ip; }
@@ -28,4 +18,3 @@
return bar(0) + foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
#endif
}
-
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -555,15 +555,15 @@
PragmaAssumeNonNullBegin(SourceLocation Loc) {
startNewLineIfNeeded();
MoveToLine(Loc);
- OS << "#pragma " << "clang assume_nonnull begin";
+ OS << "#pragma clang assume_nonnull begin";
setEmittedDirectiveOnThisLine();
}
void PrintPPOutputPPCallbacks::
PragmaAssumeNonNullEnd(SourceLocation Loc) {
startNewLineIfNeeded();
MoveToLine(Loc);
- OS << "#pragma " << "clang assume_nonnull end";
+ OS << "#pragma clang assume_nonnull end";
setEmittedDirectiveOnThisLine();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37861.115643.patch
Type: text/x-patch
Size: 1773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170918/fcd3e5c0/attachment.bin>
More information about the cfe-commits
mailing list