diff options
| author | Ted Kremenek <kremenek@apple.com> | 2012-01-20 21:40:12 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2012-01-20 21:40:12 +0000 |
| commit | f2a2f5f2bfe9da1a3e0a25934d833956b04bb8a5 (patch) | |
| tree | b372521b3a8a9159f3285c11df38c7c09c461d6c /clang | |
| parent | b9c822ab0b096efca7955bff361ab64e91d0876c (diff) | |
| download | bcm5719-llvm-f2a2f5f2bfe9da1a3e0a25934d833956b04bb8a5.tar.gz bcm5719-llvm-f2a2f5f2bfe9da1a3e0a25934d833956b04bb8a5.zip | |
Add ability to specifiy 'restrict' on parameters of builtins, and correct this oversight for scanf functions.
llvm-svn: 148573
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/Type.h | 8 | ||||
| -rw-r--r-- | clang/include/clang/Basic/Builtins.def | 12 | ||||
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 3 |
3 files changed, 17 insertions, 6 deletions
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index ed2e83763fe..a026961b20c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -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); diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index 0a16f9eb02e..3ceb687b03f 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -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) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 476d221fdf3..27bbc72e881 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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; } } |

