summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-11-06 05:41:33 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-11-06 05:41:33 +0000
commitb17ebff627415bdbe37e5c8c1c3926edb1c349ed (patch)
tree93e2ef0701decbb6e0c9c14c358e09dd7039c84f /clang
parent574caddc0dd2e9303ad347937583d41253a500e6 (diff)
downloadbcm5719-llvm-b17ebff627415bdbe37e5c8c1c3926edb1c349ed.tar.gz
bcm5719-llvm-b17ebff627415bdbe37e5c8c1c3926edb1c349ed.zip
os_log: Minor code cleanups. NFC.
Also, add a new test case and fix an incorrect comment. llvm-svn: 346209
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/OSLog.h17
-rw-r--r--clang/lib/AST/OSLog.cpp7
-rw-r--r--clang/lib/AST/PrintfFormatString.cpp2
-rw-r--r--clang/test/CodeGen/builtins.c5
4 files changed, 13 insertions, 18 deletions
diff --git a/clang/include/clang/AST/OSLog.h b/clang/include/clang/AST/OSLog.h
index 1e60a237b77..41e5c5a9ced 100644
--- a/clang/include/clang/AST/OSLog.h
+++ b/clang/include/clang/AST/OSLog.h
@@ -72,18 +72,17 @@ private:
public:
OSLogBufferItem(Kind kind, const Expr *expr, CharUnits size, unsigned flags)
- : TheKind(kind), TheExpr(expr), Size(size), Flags(flags) {}
+ : TheKind(kind), TheExpr(expr), Size(size), Flags(flags) {
+ assert(((Flags == 0) || (Flags == IsPrivate) || (Flags == IsPublic)) &&
+ "unexpected privacy flag");
+ }
OSLogBufferItem(ASTContext &Ctx, CharUnits value, unsigned flags)
: TheKind(CountKind), ConstValue(value),
Size(Ctx.getTypeSizeInChars(Ctx.IntTy)), Flags(flags) {}
unsigned char getDescriptorByte() const {
- unsigned char result = 0;
- if (getIsPrivate())
- result |= IsPrivate;
- if (getIsPublic())
- result |= IsPublic;
+ unsigned char result = Flags;
result |= ((unsigned)getKind()) << 4;
return result;
}
@@ -92,7 +91,6 @@ public:
Kind getKind() const { return TheKind; }
bool getIsPrivate() const { return (Flags & IsPrivate) != 0; }
- bool getIsPublic() const { return (Flags & IsPublic) != 0; }
const Expr *getExpr() const { return TheExpr; }
CharUnits getConstValue() const { return ConstValue; }
@@ -120,11 +118,6 @@ public:
Items, [](const OSLogBufferItem &Item) { return Item.getIsPrivate(); });
}
- bool hasPublicItems() const {
- return llvm::any_of(
- Items, [](const OSLogBufferItem &Item) { return Item.getIsPublic(); });
- }
-
bool hasNonScalar() const {
return llvm::any_of(Items, [](const OSLogBufferItem &Item) {
return Item.getKind() != OSLogBufferItem::ScalarKind;
diff --git a/clang/lib/AST/OSLog.cpp b/clang/lib/AST/OSLog.cpp
index cf20706c4b3..9124fd58a05 100644
--- a/clang/lib/AST/OSLog.cpp
+++ b/clang/lib/AST/OSLog.cpp
@@ -120,12 +120,11 @@ public:
ArgsData.back().FieldWidth = Args[FS.getFieldWidth().getArgIndex()];
}
- if (FS.isPrivate()) {
+ if (FS.isPrivate())
ArgsData.back().Flags |= OSLogBufferItem::IsPrivate;
- }
- if (FS.isPublic()) {
+ else if (FS.isPublic())
ArgsData.back().Flags |= OSLogBufferItem::IsPublic;
- }
+
return true;
}
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index 96a8f258ed3..71c28de99c9 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -127,7 +127,7 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H,
do {
StringRef Str(I, E - I);
- std::string Match = "^[\t\n\v\f\r ]*(private|public)[\t\n\v\f\r ]*(,|})";
+ std::string Match = "^[[:space:]]*(private|public)[[:space:]]*(,|})";
llvm::Regex R(Match);
SmallVector<StringRef, 2> Matches;
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 6ca3c414cf3..829f725617f 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -440,7 +440,10 @@ void test_builtin_os_log(void *buf, int i, const char *data) {
// CHECK: call void @__os_log_helper_1_2_1_8_34(
__builtin_os_log_format(buf, "%{ xyz, public }s", "abc");
- // The last privacy annotation in the string wins.
+ // CHECK: call void @__os_log_helper_1_3_1_8_33(
+ __builtin_os_log_format(buf, "%{ xyz, private }s", "abc");
+
+ // The strictest privacy annotation in the string wins.
// CHECK: call void @__os_log_helper_1_3_1_8_33(
__builtin_os_log_format(buf, "%{ private, public, private, public}s", "abc");
OpenPOWER on IntegriCloud