]> granicus.if.org Git - clang/commitdiff
Add ability to specifiy 'restrict' on parameters of builtins, and correct this oversi...
authorTed Kremenek <kremenek@apple.com>
Fri, 20 Jan 2012 21:40:12 +0000 (21:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 20 Jan 2012 21:40:12 +0000 (21:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148573 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
include/clang/Basic/Builtins.def
lib/AST/ASTContext.cpp

index ed2e83763febe8f265b58aeccebdb8200cc5b7e1..a026961b20c492e97d75a5e9a35f8866bbabed8f 100644 (file)
@@ -639,6 +639,14 @@ public:
   QualType withVolatile() const {
     return withFastQualifiers(Qualifiers::Volatile);
   }
+  
+  /// Add the restrict qualifier to this QualType.
+  void addRestrict() {
+    addFastQualifiers(Qualifiers::Restrict);
+  }
+  QualType withRestrict() const {
+    return withFastQualifiers(Qualifiers::Restrict);
+  }
 
   QualType withCVRQualifiers(unsigned CVR) const {
     return withFastQualifiers(CVR);
index 0a16f9eb02ed2ee493f466d6941dc1fd41a8687a..3ceb687b03f3494d2185fd94acd4fb1411247810 100644 (file)
@@ -662,12 +662,12 @@ LIBBUILTIN(vprintf, "icC*a",      "fP:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfprintf, "i.",        "fP:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsprintf, "ic*cC*a",   "fP:1:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(scanf, "icC*.",        "fs:0:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(fscanf, "iP*cC*.",     "fs:1:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(sscanf, "icC*cC*.",    "fs:1:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(vscanf, "icC*a",       "fS:0:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(vfscanf, "iP*cC*a",    "fS:1:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(vsscanf, "icC*cC*a",   "fS:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(scanf, "icC*R.",       "fs:0:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(fscanf, "iP*RcC*R.",   "fs:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(vscanf, "icC*Ra",      "fS:0:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
 // C99
 LIBBUILTIN(longjmp, "vJi",        "fr",    "setjmp.h", ALL_LANGUAGES)
 
index 476d221fdf3b51aff13a120ecf709b7c84d27bac..27bbc72e881b80f371da1a2ef4d9925362b8fefb 100644 (file)
@@ -6468,6 +6468,9 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
     case 'D':
       Type = Context.getVolatileType(Type);
       break;
+    case 'R':
+      Type = Type.withRestrict();
+      break;
     }
   }