summaryrefslogtreecommitdiff
path: root/include/clang/Basic/DiagnosticIDs.h
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-26 06:17:37 +0000
committerAlp Toker <alp@nuanti.com>2014-01-26 06:17:37 +0000
commita2474459beca778d352a16e6463cf4dd9e29dc06 (patch)
tree446314f9ee030469e4c144cec8db4f4ec51e279f /include/clang/Basic/DiagnosticIDs.h
parentd6de61539c778f1d8449208c381234d13f7643cb (diff)
downloadclang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.gz
clang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.bz2
clang-a2474459beca778d352a16e6463cf4dd9e29dc06.tar.xz
Enforce safe usage of DiagnosticsEngine::getCustomDiagID()
Replace the last incorrect uses and templatize the function to require a compile-time constant string preventing further misuse. The diagnostic formatter expects well-formed input and has undefined behaviour with arbitrary input or crafted user strings in source files. Accepting user input would also have caused unbounded generation of new diagnostic IDs which can be problematic in long-running sessions or language bindings. This completes the work to fix several incorrect callers that passed user input or raw messages to the diagnostics engine where a constant format string was expected. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/DiagnosticIDs.h')
-rw-r--r--include/clang/Basic/DiagnosticIDs.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h
index 2be4acf2fa..0152f25fa6 100644
--- a/include/clang/Basic/DiagnosticIDs.h
+++ b/include/clang/Basic/DiagnosticIDs.h
@@ -124,11 +124,16 @@ public:
DiagnosticIDs();
~DiagnosticIDs();
- /// \brief Return an ID for a diagnostic with the specified message and level.
+ /// \brief Return an ID for a diagnostic with the specified format string and
+ /// level.
///
/// If this is the first request for this diagnostic, it is registered and
/// created, otherwise the existing ID is returned.
- unsigned getCustomDiagID(Level L, StringRef Message);
+
+ // FIXME: Replace this function with a create-only facilty like
+ // createCustomDiagIDFromFormatString() to enforce safe usage. At the time of
+ // writing, nearly all callers of this function were invalid.
+ unsigned getCustomDiagID(Level L, StringRef FormatString);
//===--------------------------------------------------------------------===//
// Diagnostic classification and reporting interfaces.