• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_  // NOLINT
18 #define _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_
19 
20 #include <list>
21 #include <string>
22 #include <utility>
23 
24 #include "clang/Lex/Pragma.h"
25 
26 namespace clang {
27   class Token;
28   class Preprocessor;
29 }
30 
31 namespace slang {
32 
33 typedef std::list< std::pair<std::string, std::string> > PragmaList;
34 
35 class PragmaRecorder : public clang::PragmaHandler {
36  private:
37   PragmaList *mPragmas;
38 
39   static bool GetPragmaNameFromToken(const clang::Token &Token,
40                                      std::string &PragmaName);
41 
42   static bool GetPragmaValueFromToken(const clang::Token &Token,
43                                       std::string &PragmaValue);
44 
45  public:
46   explicit PragmaRecorder(PragmaList *Pragmas);
47 
48   virtual void HandlePragma(clang::Preprocessor &PP,
49                             clang::PragmaIntroducerKind Introducer,
50                             clang::Token &FirstToken);
51 };
52 }  // namespace slang
53 
54 #endif  // _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_  NOLINT
55